knitr::opts_chunk$set(echo = TRUE)
“The Last Judgment” by Michelangelo
“The Last Judgment” by Michelangelo

Abstract


Alexis de Tocqueville, a prominent French writer from the early 19th century who extensively studied democracy in America, recognized the significant influence religion has on American society. He observed that American civilization uniquely combines the spirit of religion and the spirit of liberty, blending them harmoniously.

Nearly two centuries later, religion continues to shape the beliefs and values of Americans. To explore the relationship between religious beliefs and social and political views, the Pew Research Center’s Forum on Religion & Public Life conducted a comprehensive survey on religion in America. The first report, published in February 2008, examined the religious affiliations of the American public, as well as changes in affiliation and the diversity of religious traditions.

The latest release of the Landscape Survey provides detailed information on various aspects of religious beliefs and practices in America. This includes the importance of religion in people’s lives, belief in God and the afterlife, worship attendance, and participation in religious activities. The study also investigates public opinion on religion’s impact on society, conflicts between religion and society, and the relationship between religion and life satisfaction.

Using survey responses, the report analyzes the diversity of opinion on political and public policy issues among different religious groups in the United States, including those who are unaffiliated or nominally affiliated with a religious tradition. These issues range from ideological orientation to views on social issues, government size and role, environmental concerns, and foreign affairs.

The Landscape Survey is based on a nationwide survey conducted from May 8 to August 13, 2007, with over 35,000 adult participants. Additional oversampling was conducted for Eastern Orthodox Christians, Buddhists, and Hindus. The study also incorporates data from a 2007 survey of American Muslims, conducted in partnership with other Pew Research Center projects, resulting in interviews with over 36,000 Americans in total.


Keywords


  1. Religion in America
  2. American civilization
  3. Religious beliefs and practices
  4. Social and political views
  5. Diversity of religious traditions
  6. Public opinion on religious impact
  7. Political and public policy issues
  8. Statistical modeling and analysis


Introduction


I would like to divide this project into several chapters, in each chapter I’m gonna search for the answer of my own questions.


Chapter 1 (Religious Beliefs and Practices)


Question: How do Americans’ religious beliefs and practices vary across different demographic groups, and what insights can be gained by examining measures such as the importance of religion in people’s lives, belief in God, frequency of prayer, and frequency of worship service attendance?

Explanation: This chapter delves into the diverse religious beliefs and practices of American adults. It begins by exploring the importance individuals attribute to religion in their lives and delves into their perspectives on God, Scripture, miracles, and other religious beliefs. Furthermore, it discusses worship and other congregational activities, as well as devotional practices and spiritual experiences. The chapter also addresses beliefs about religion, including exclusivity in claims to salvation and moral considerations. Along the way, four key measures of religious commitment – importance of religion in people’s lives, belief in God, frequency of prayer, and frequency of worship service attendance – are highlighted for demographic analysis. These measures serve as lenses through which to examine social and political attitudes within religious traditions in subsequent chapters.


Chapter 2 (Social and Political Views)


Question: How do Americans’ religious affiliations and levels of religious commitment influence their views on social and political issues?

Explanation: This chapter delves into the relationship between Americans’ religious affiliations, beliefs, practices, and their social and political attitudes. Despite religion being a secondary source for many, the analysis reveals strong correlations between religious affiliation, beliefs, and social attitudes.

Chapter 4 (Religious Switching and Intermarriage)


Question: How can we model and understand the trends and dynamics of religious affiliation changes among American adults?

Explanation: In this revised chapter, our analysis shifts from a broad discussion of religious switching and intermarriage to a more focused examination of the factors influencing religious affiliation changes over time. Utilizing advanced statistical models, including decision trees and Generalized Linear Models (GLM), we delve into the intricacies of religious identity transitions from childhood to adulthood. By examining the predictive power of sociodemographic variables such as income, education, age, and marital status, our models shed light on the underlying patterns that guide religious affiliation changes. We explore the significance of these variables in contributing to an individual’s likelihood of shifting religious identity, providing a nuanced understanding of the factors at play.


Data Description


2007 Religious Landscape Study


Summary: The 2007 U.S. Religious Landscape Study is a comprehensive telephone survey that explores the religious affiliations, beliefs, and practices of the American public. Conducted by the Pew Research Center, this survey provides insights into the religious composition of the U.S. and examines how religion intersects with various aspects of public life.


Dataset Details:

Aspect Details
Survey Conducted By Pew Research Center
Date of Survey 2007
Sample Size Over 35,000 U.S. Adults
Methodology Telephone survey (landline and cellphones)
Geographic Coverage National (U.S.)
Population Coverage 97% of non-institutionalized U.S. adult population
Non-Coverage 3% of U.S. adults not reachable by telephone or non-English/Spanish speakers
Data Availability Publicly available for analysis
Funding The Pew Charitable Trusts, supported by Lilly Endowment Inc.
Research Purpose To inform about religious affiliations, beliefs, and practices; and understand their influence on various aspects of public life


2014 Religious Landscape Study


Summary: The 2014 Religious Landscape Study, following up on the initial 2007 survey, provides updated data on religious affiliations and the changing religious composition in the United States. This extensive survey captures current trends and shifts in religion within the American adult population.


Dataset Details:

Aspect Details
Survey Conducted By Pew Research Center
Date of Survey June 4 - Sept. 30, 2014
Sample Size 35,071 U.S. Adults
Methodology Telephone survey (60% cellphones, 40% landlines)
Geographic Coverage National (U.S.), with at least 300 interviews in every state and the District of Columbia
Language English and Spanish
Population Coverage 97% of non-institutionalized U.S. adult population
Non-Coverage 3% of U.S. adults not reachable by telephone or non-English/Spanish speakers
Data Availability Publicly available for analysis
Funding The Pew Charitable Trusts, supported by Lilly Endowment Inc.
Research Purpose To provide insights into the religious beliefs and practices, as well as the social and political attitudes of the U.S. adults

These datasets are instrumental for analyzing changes over time in religious beliefs and practices among U.S. adults. They offer a wealth of information that can be utilized to study the relationship between religion and a variety of sociodemographic factors. The data is publicly available and provides a representative snapshot of the religious composition of the United States for the respective years.


Chapter 1 : Religious Beliefs and Practices


Religion Composition


This statistical breakdown provides a clear picture of the religious affiliations among survey respondents, focusing on those with more than 100 individuals per religion. It highlights the diversity of religious identities represented in the survey, including Agnostic, Atheist, Buddhist, Hindu, Jewish, Mormon, Muslim, Orthodox, Protestant, Roman Catholic, and others. The larger representation of categories like Protestant and Roman Catholic indicates their significant presence in the surveyed population. Additionally, the inclusion of categories such as “Nothing in particular”, “Agnostic”, “Atheist” underscores the prevalence of religious non-affiliation among respondents. Overall, this breakdown offers a straightforward overview of the religious diversity within the survey sample, facilitating further analysis of attitudes and beliefs across different religious affiliations.


# Load the necessary library
library(readr)
library(igraph)
library(ggraph)
library(colormap)
library(oce)
library(pROC)
library(ggplot2)
library(magrittr) # needs to be run every time you start R and want to use %>%
library(dplyr)    # alternatively, this also loads %>%
library(plotly)
library(kableExtra)
library(tidyr)
library(rpart)
library(randomForest)
library(caret)

# Load the dataset 2007
survey_data_2007 <- read_csv("Dataset_2007.csv")
# Load the dataset 2014
survey_data_2014 <- read_csv("Dataset_2014.csv")


# Let's say we have the data frame 'survey_data'
survey_data <- data.frame(survey_data_2007$q16)


# Assuming 'q16' is the column for religion
religion_counts_2007 <- survey_data_2007 %>%
  count(q16) %>%
  filter(n > 100)

# Rename the columns for clarity
colnames(religion_counts_2007) <- c("Religion", "Respondents")

# Calculate the total number of respondents
total_respondents <- sum(religion_counts_2007$Respondents)

# Calculate percentages
religion_counts_2007 <- religion_counts_2007 %>%
  mutate(Percentage = (Respondents / total_respondents) * 100)

options(repr.plot.width = 8, repr.plot.height =5)
# Create the bar plot
p <- ggplot(religion_counts_2007, aes(x = reorder(Religion, -Percentage), y = Percentage, fill = Religion) , width = 60 , height = 12) + 
  geom_bar(stat = "identity") + # Use identity to use the heights of the bars as provided in the data frame
  coord_flip() +  # Flip coordinates to have horizontal bars
  theme_minimal() +  # Use a minimal theme for aesthetics
  labs(title = "Number of Respondents",
       x = "",
       y = "") +
  theme(legend.position = "none")  # Remove the legend


# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 500)

# Show the interactive plot in your default browser

interactive_plot




Importance of Religion


Question:

“How important is religion in your life?”

  • Very Important: A significant proportion of respondents from various religious backgrounds, including Jehovah’s Witnesses, Mormons, Muslims, Orthodox Christians, Protestants, Roman Catholics, and Unitarians, consider religion to be highly important in their lives. These individuals prioritize religious beliefs and practices as integral aspects of their identity and worldview.

  • Somewhat Important: Another sizable segment of respondents, spanning diverse religious groups such as Buddhists, Hindus, and those with no particular religious affiliation, view religion as somewhat important in their lives. While not as central as for those who consider it very important, these individuals still recognize the value of religious beliefs and traditions to some extent.

  • Not Too Important or Not at All Important: A minority of respondents, particularly atheists and agnostics, express that religion holds little to no importance in their lives. They either do not believe in religious concepts or do not actively engage with religious practices, indicating a lack of significance of religion in shaping their personal identities or guiding their daily lives.


religion_importance <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q21)) %>%  # Ensure q16 and q21 are not NA
  group_by(q16, q21) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q21)



p <- ggplot(religion_importance, aes(x = q16, y = q21, fill = Percentage)) +
  geom_tile() + # Create the tiles for the heatmap
  scale_fill_gradient(low = "white", high = "steelblue") + # Gradient from white (low) to steel blue (high)
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), axis.text.y = element_text(size = 12), title = element_text(size = 20)) +
  labs(title = "Percentage of Responses on the Importance of Religion by Religious Group",
       x = "Religion",
       y = "Importance",
       fill = "Percentage")

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 750)

# Show the interactive plot in your default browser

interactive_plot


Conclusion:

The data underscores the diversity of attitudes toward religion among individuals of various religious affiliations. While some prioritize religion as a fundamental aspect of their lives, others assign varying degrees of importance to it, and some do not consider it significant at all. Understanding these perspectives is essential for appreciating the complex role that religion plays in shaping individual identities and societal dynamics.


religion_importance_selected <- select(religion_importance, q16, q21, Percentage)


religion_importance_wide <- pivot_wider(
  religion_importance_selected,
  names_from = q21,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(religion_importance_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(religion_importance_wide, "html", align = c('l', rep('c', 10))) %>%
  kable_styling("striped", full_width = F) %>%
  add_header_above(c(" " = 1, "How important is religion in your life" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
How important is religion in your life
Religion Don’t know/Refused (VOL.) Not at all important Not too important Somewhat important Very important
Agnostic (not sure if there is a God) 1.4527845 43.8256659 33.414044 16.101695 5.205811
Atheist (do not believe in God) 2.3300971 74.5631068 11.844660 7.766990 3.495146
Buddhist 2.1897810 6.3260341 17.761557 37.469586 36.253041
Christian (VOL) 3.2534247 4.7945205 7.876712 24.143836 59.931507
Don’t know/Refused (VOL) 19.2000000 18.8000000 15.600000 25.600000 20.800000
Hindu 0.7782101 3.1128405 12.451362 41.634241 42.023346
Jehovah’s Witness (VOL) 0.9389671 0.4694836 1.408451 8.450704 88.732394
Jewish (Judaism) 0.8797654 9.8240469 18.035191 40.469208 30.791789
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 0.0000000 1.0327022 2.409639 10.843374 85.714286
Muslim (Islam) 0.0000000 4.3103448 7.758621 23.275862 64.655172
Nothing in particular 1.7534394 28.2168870 24.143512 27.596439 18.289722
Orthodox (Greek, Russian, or some other orthodox church) 0.0000000 3.3057851 8.815427 30.578512 57.300275
Protestant 0.5557674 1.3676238 4.724023 22.497684 70.854901
Roman Catholic 0.4970797 1.6527899 7.033677 32.757549 58.058904
Unitarian (Universalist) (VOL) 3.2467532 11.0389610 13.636364 37.662338 34.415584



Importance of Religion and Demographic Groups


The survey highlights a significant gender disparity regarding the importance of religion in individuals’ lives, with women more likely than men to consider religion very important. This trend persists across various religious groups.

Furthermore, age plays a substantial role in determining the importance of religion, with older adults more likely than younger adults to prioritize it. For instance, less than half (45%) of adults under 30 view religion as very important, contrasting with over two-thirds (68%) of those aged 60 and older.

Regarding education, the survey indicates that individuals with lower levels of education tend to place greater importance on religion in their lives.


religion_importance_gender <- survey_data_2007 %>%
  group_by(sex) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(sex), !is.na(q21)) %>%  # Ensure q16 and q21 are not NA
  group_by(sex, q21) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(sex) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(sex, q21)


religion_importance_gender_selected <- select(religion_importance_gender, sex, q21, Percentage)


religion_importance_gender_wide <- pivot_wider(
  religion_importance_gender_selected,
  names_from = q21,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(religion_importance_gender_wide)[1] <- "Sex"

# Create the table with kable and add styling with kableExtra
table <- kable(religion_importance_gender_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "How important is religion in your life" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
How important is religion in your life
Sex Don’t know/Refused (VOL.) Not at all important Not too important Somewhat important Very important
Female 0.8928108 4.988321 6.405398 23.01064 64.70283
Male 1.0005525 9.250506 11.540114 28.59861 49.61021



filtered_data_age <- survey_data_2007 %>%
  filter(!is.na(age) & as.numeric(age) >= 10)  # This removes NA values and ensures age is 10 or more
## Warning: There was 1 warning in `filter()`.
## ℹ In argument: `!is.na(age) & as.numeric(age) >= 10`.
## Caused by warning:
## ! NAs introduced by coercion
filtered_data_age <- filtered_data_age %>%
  mutate(age_numeric = as.numeric(as.character(age)),  # Convert age from string to numeric
         AgeGroup = cut(age_numeric,
                        breaks = c(10, 20, 30, 40, 50, 60, 70, 80, Inf),
                        labels = c("10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80+"),
                        right = FALSE)) %>%
  filter(!is.na(AgeGroup))  # Exclude entries that could not be converted to numeric (including "Don’t know/Refused (VOL.)")


religion_importance_age <- filtered_data_age %>%
  group_by(AgeGroup) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(AgeGroup), !is.na(q21)) %>%  # Ensure q16 and q21 are not NA
  group_by(AgeGroup, q21) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(AgeGroup) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(AgeGroup, q21)


religion_importance_age_selected <- select(religion_importance_age, AgeGroup, q21, Percentage)


religion_importance_age_wide <- pivot_wider(
  religion_importance_age_selected,
  names_from = q21,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(religion_importance_gender_wide)[1] <- "Age"

# Create the table with kable and add styling with kableExtra
table <- kable(religion_importance_age_wide, "html") %>%
  kable_styling("striped", full_width = F) %>%
  add_header_above(c(" " = 1, "How important is religion in your life" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box(height  = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
How important is religion in your life
AgeGroup Don’t know/Refused (VOL.) Not at all important Not too important Somewhat important Very important
10-20 0.1042753 10.636079 12.200209 35.03650 42.02294
20-30 0.5787390 8.559245 12.671337 31.98294 46.20774
30-40 0.6489676 7.649951 10.383481 29.61652 51.70108
40-50 0.7569012 6.144257 9.349956 27.17424 56.57465
50-60 0.8131183 7.074129 9.147581 25.65388 57.31129
60-70 1.0150444 6.978430 7.123437 22.40348 62.47961
70-80 1.0983123 5.973748 5.679079 18.53737 68.71149
80+ 1.2072435 4.778672 4.728370 17.85714 71.42857



religion_importance_edu <- survey_data_2007 %>%
  group_by(educ) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(educ), !is.na(q31)) %>%  # Ensure q16 and q31 are not NA
  group_by(educ, q31) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(educ) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(educ, q31)


religion_importance_edu_selected <- select(religion_importance_edu, educ, q31, Percentage)


religion_importance_edu_wide <- pivot_wider(
  religion_importance_edu_selected,
  names_from = q31,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(religion_importance_edu_wide)[1] <- "Education"

# Create the table with kable and add styling with kableExtra
table <- kable(religion_importance_edu_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "How important is religion in your life" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
How important is religion in your life
Education Absolutely certain Don’t know/refused (VOL.) Fairly certain Not at all certain Not too certain
College graduate (B.S., B.A., or other 4-year degree) 74.93427 0.5550687 20.17236 1.2269939 3.111306
Don’t know/Refused (VOL.) 76.85185 2.7777778 18.98148 0.0000000 1.388889
High school graduate (Grade 12 or GED certificate) 81.14176 0.5879838 15.45863 0.5772931 2.234338
High school incomplete (Grades 9-11) 80.89725 0.8200675 15.43657 0.3376749 2.508442
None, or grade 1-8 75.63218 1.9540230 17.93103 1.3793103 3.103448
Post-graduate training or professional schooling after colle 70.87993 0.9706689 22.36759 1.2449884 4.536822
Some college, no 4-year degree (including associate degree) 80.16148 0.6920415 16.18608 0.6535948 2.306805
Technical, trade, or vocational school AFTER high school 82.21344 0.7905138 14.72332 0.6916996 1.581028



Religious Beliefs


God


The survey reveals a widespread belief in God or a universal spirit among American adults, with more than nine-in-ten (92%) affirming this belief. This includes the vast majority of individuals from every major religious tradition, with virtually all Mormon respondents and at least 95% of Catholics, Orthodox Christians, Jehovah’s Witnesses, and members of all three Protestant traditions expressing belief. Even among those not affiliated with a specific religious group, seven-in-ten acknowledge their belief in God or a universal spirit. Notably, a substantial portion of self-described atheists (21%) and more than half of self-described agnostics (55%) also profess belief in God or a universal spirit.

God_belief <- survey_data_2007 %>%
  filter(q30 == 'Yes') %>% 
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q30)) %>%  # Ensure q16 and q21 are not NA
  group_by(q16, q31) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q31)



p <- ggplot(God_belief, aes(x = q16, y = q31, fill = Percentage)) +
  geom_tile() + # Create the tiles for the heatmap
  scale_fill_gradient(low = "white", high = "steelblue") + # Gradient from white (low) to steel blue (high)
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), axis.text.y = element_text(size = 12) , title = element_text(size = 15)) +
  labs(title = "believe in God or a universal spirit",
       x = "Religion",
       y = "",
       fill = "Percentage")

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 750)

# Show the interactive plot in your default browser

interactive_plot


There is notable variability in the certainty and nature of individuals’ beliefs in God. While at least nine-in-ten Mormons, Jehovah’s Witnesses and Protestant express absolute certainty in the existence of God, smaller majorities of other religious groups also share this conviction. Specifically, Muslims (82%), Catholics (72%), Orthodox Christians (71%), and Hindus (57%) report being completely certain of the existence of God or a universal spirit. In contrast, fewer than half of Jews (41%) and Buddhists (39%) express absolute certainty in the existence of God or a universal spirit. Notably, approximately one-third of the unaffiliated (36%) assert absolute certainty in the existence of God or a universal spirit, with 8% of atheists claiming absolute certainty in this belief.


Conception of God


  • God as a Person: The majority of respondents across different religious affiliations perceive God as a person. This belief is particularly strong among Jehovah’s Witnesses (86.06%), Mormons (92.39%), and Protestants (73.98%).

  • God as an Impersonal Force: A significant portion of respondents, though smaller compared to those who view God as a person, conceive of God as an impersonal force. This perspective is notably prevalent among Buddhists (61.84%), Hindus (59.75%), and Unitarians (61.11%).

  • Other/Both/Neither: Some respondents express conceptions of God that do not fit neatly into the categories of “person” or “impersonal force.” This group includes individuals who may perceive God in multifaceted ways or hold beliefs outside the typical paradigms of personal or impersonal deities.


God_conception <- survey_data_2007 %>%
  filter(q30 == 'Yes') %>% 
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q32)) %>%  # Ensure q16 and q21 are not NA
  group_by(q16, q32) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q32)


God_conception_selected <- select(God_conception, q16, q32, Percentage)


God_conception_wide <- pivot_wider(
  God_conception_selected,
  names_from = q32,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(God_conception_wide)[1] <- "God Conception"

# Create the table with kable and add styling with kableExtra
table <- kable(God_conception_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Conception of God among who believed in God" = 3, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Conception of God among who believed in God
God Conception Both/Neither/Other (VOL.) Don’t know/refused (VOL.) God is a person God is an impersonal force
Agnostic (not sure if there is a God) 5.909091 3.6363636 24.54545 65.909091
Buddhist 10.855263 3.9473684 23.35526 61.842105
Christian (VOL) 6.909091 5.4545455 64.72727 22.909091
Don’t know/Refused (VOL) 13.071895 15.0326797 31.37255 40.522876
Hindu 6.779661 2.5423729 30.93220 59.745763
Jehovah’s Witness (VOL) 3.365385 0.9615385 86.05769 9.615385
Jewish (Judaism) 4.821429 4.8214286 27.50000 62.857143
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 1.730104 0.8650519 92.38754 5.017301
Muslim (Islam) 8.333333 3.7037037 42.59259 45.370370
Nothing in particular 4.584626 5.4119269 41.84764 48.155808
Orthodox (Greek, Russian, or some other orthodox church) 6.936416 6.6473988 49.42197 36.994220
Protestant 4.188395 3.2841451 73.97648 18.550982
Roman Catholic 4.210258 4.0316407 64.53177 27.226333
Unitarian (Universalist) (VOL) 9.523810 6.3492063 23.01587 61.111111


Conclusion:

The data underscores the diversity of beliefs regarding the nature of God among individuals who identify with various religious traditions. While many perceive God as a personal entity, others conceptualize God as an impersonal force or hold alternative views. Understanding these diverse conceptions enriches our insight into the complex and multifaceted nature of religious beliefs across different faith communities.


Belief in God and Demographic Groups


Women demonstrate a significantly higher inclination than men to express absolute certainty in their belief in a personal God (81% vs. 72%).


God_belief_gender <- survey_data_2007 %>%
  filter(q30 == 'Yes') %>%
  group_by(sex) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(sex), !is.na(q31)) %>%  # Ensure q16 and q31 are not NA
  group_by(sex, q31) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(sex) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(sex, q31)


God_belief_gender_selected <- select(God_belief_gender, sex, q31, Percentage)


God_belief_gender_wide <- pivot_wider(
  God_belief_gender_selected,
  names_from = q31,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(God_belief_gender_wide)[1] <- "Sex"

# Create the table with kable and add styling with kableExtra
table <- kable(God_belief_gender_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Belief in God" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Belief in God
Sex Absolutely certain Don’t know/refused (VOL.) Fairly certain Not at all certain Not too certain
Female 81.99158 0.7104990 14.72919 0.5465377 2.022189
Male 72.96798 0.7594417 21.35331 1.1904762 3.728790


Furthermore, older Americans are notably more likely than younger Americans to profess certain belief in a personal God. Among individuals aged 60 and above, almost eight-in-ten (81%) express this conviction, in contrast with (70%) of those under the age of 30.


God_belief_age <- filtered_data_age %>%
  filter(q30 == 'Yes') %>%
  group_by(sex) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(AgeGroup), !is.na(q31)) %>%  # Ensure q16 and q31 are not NA
  group_by(AgeGroup, q31) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(AgeGroup) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(AgeGroup, q31)


God_belief_age_selected <- select(God_belief_age, AgeGroup, q31, Percentage)


God_belief_age_wide <- pivot_wider(
  God_belief_age_selected,
  names_from = q31,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(God_belief_age_wide)[1] <- "AgeGroup"

# Create the table with kable and add styling with kableExtra
table <- kable(God_belief_age_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Belief in God" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Belief in God
AgeGroup Absolutely certain Don’t know/refused (VOL.) Fairly certain Not at all certain Not too certain
10-20 69.57041 0.4773270 24.70167 1.1933174 4.057279
20-30 71.78884 0.5379960 22.86483 0.7733692 4.034970
30-40 75.30416 0.2774813 20.57631 0.8324440 3.009605
40-50 78.99427 0.4296626 17.23425 0.7638447 2.577976
50-60 77.52907 0.6395349 18.21221 0.8139535 2.805233
60-70 80.54747 0.7377208 15.41448 0.8542031 2.446127
70-80 82.28719 1.2611063 13.47091 0.9458298 2.034967
80+ 79.96760 2.1058315 14.20086 0.8639309 2.861771


In general, Americans with a college education tend to be slightly less inclined to believe with certainty in a personal God compared to those without a degree.


God_belief_edu <- survey_data_2007 %>%
  group_by(educ) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(educ), !is.na(q21)) %>%  # Ensure q16 and q21 are not NA
  group_by(educ, q21) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(educ) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(educ, q21)


God_belief_edu_selected <- select(God_belief_edu, educ, q21, Percentage)


God_belief_edu_wide <- pivot_wider(
  God_belief_edu_selected,
  names_from = q21,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(God_belief_edu_wide)[1] <- "Education"

# Create the table with kable and add styling with kableExtra
table <- kable(God_belief_edu_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "How important is religion in your life" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
How important is religion in your life
Education Don’t know/Refused (VOL.) Not at all important Not too important Somewhat important Very important
College graduate (B.S., B.A., or other 4-year degree) 0.7468658 8.015471 10.576154 26.79381 53.86770
Don’t know/Refused (VOL.) 8.9147287 4.263566 6.589147 23.25581 56.97674
High school graduate (Grade 12 or GED certificate) 0.7780922 5.254648 7.225142 26.35408 60.38804
High school incomplete (Grades 9-11) 1.2385321 4.724771 6.422018 22.98165 64.63303
None, or grade 1-8 1.7957351 3.030303 3.815937 16.94725 74.41077
Post-graduate training or professional schooling after colle 0.8466777 10.914780 11.522179 25.28990 51.42647
Some college, no 4-year degree (including associate degree) 0.9368244 6.665866 8.527504 26.00288 57.86692
Technical, trade, or vocational school AFTER high school 1.1173184 5.400372 7.355680 20.85661 65.27002


Afterlife


The data presents varying levels of certainty among individuals from different religious backgrounds regarding the existence of life after death:

  • Absolutely Certain: A substantial proportion of respondents across several religious affiliations express absolute certainty about life after death. This belief is particularly strong among Mormons (90.86%), Jehovah’s Witnesses (88.89%), and Muslims (86.36%).

  • Fairly Certain: Many respondents indicate a high degree of confidence, albeit not absolute certainty, in the existence of life after death. This sentiment is prevalent among Christians (Protestants: 76.48%, Christians: 73.73%, Catholics: 61.05%) and members of other religious groups.

  • Uncertainty: Some respondents express varying degrees of uncertainty regarding life after death. This uncertainty is evident across different religious affiliations, with notable proportions of individuals falling into categories such as “Don’t know/refused” or “Not at all certain.”


Afterlife_belief <- survey_data_2007 %>%
  filter(q33 == 'Yes') %>% 
  group_by(q16) %>% 
  filter(n() > 50) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q34)) %>%  # Ensure q16 and q21 are not NA
  group_by(q16, q34) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q34)


Afterlife_belief_selected <- select(Afterlife_belief, q16, q34, Percentage)


Afterlife_belief_wide <- pivot_wider(
  Afterlife_belief_selected,
  names_from = q34,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Afterlife_belief_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Afterlife_belief_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Life After Death" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 


table
Life After Death
Religion Absolutely certain Don’t know/refused (VOL.) Fairly certain Not at all certain Not too certain
Agnostic (not sure if there is a God) 34.70149 0.7462687 37.686567 8.5820896 18.283582
Atheist (do not believe in God) 32.91139 2.5316456 43.037975 2.5316456 18.987342
Buddhist 47.77778 1.8518519 38.518518 2.9629630 8.888889
Christian (VOL) 73.73272 1.8433180 19.815668 1.3824885 3.225807
Don’t know/Refused (VOL) 52.52525 3.0303030 32.323232 4.0404040 8.080808
Hindu 50.60976 0.6097561 32.926829 4.2682927 11.585366
Jehovah’s Witness (VOL) 88.88889 1.1111111 6.666667 0.0000000 3.333333
Jewish (Judaism) 42.17391 0.8695652 37.826087 6.0869565 13.043478
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 90.86116 0.0000000 7.557118 0.0000000 1.581722
Muslim (Islam) 86.36364 1.1363636 9.090909 2.2727273 1.136364
Nothing in particular 46.72173 1.1874032 38.461539 2.3748064 11.254517
Orthodox (Greek, Russian, or some other orthodox church) 63.11787 0.7604563 31.178707 1.1406844 3.802281
Protestant 76.47719 0.6271869 19.654057 0.5017495 2.739816
Roman Catholic 61.05181 0.8634223 31.632653 0.8320251 5.620094
Unitarian (Universalist) (VOL) 41.42857 1.4285714 47.142857 1.4285714 8.571429


Conclusion:

The data highlights the diversity of beliefs concerning life after death among individuals from various religious traditions. While some express unwavering certainty, others hold more nuanced or uncertain perspectives. Understanding these diverse beliefs provides valuable insight into the complex and multifaceted nature of religious beliefs surrounding the concept of life after death.


Belief in Heaven and Hell

Belief in Heaven Across Different Religious Affiliations:

The data reflects the varying degrees of belief in heaven among individuals from diverse religious backgrounds:

  • High Belief: A significant proportion of respondents across several religious groups express a strong belief in heaven. This belief is particularly prominent among Mormons (94.84%), Muslims (83.62%), and Protestants (81.96%).

  • Moderate Belief: Some respondents exhibit a moderate level of belief in heaven. This category includes individuals from Orthodox Christian traditions (71.90%) and various Christian denominations.

  • Low Belief: Certain religious affiliations demonstrate lower levels of belief in heaven compared to others. For instance, Buddhists (29.68%) and individuals identifying with “Nothing in particular” (45.40%) exhibit lower rates of belief in heaven.

  • Uncertainty: A minority of respondents either express uncertainty about their belief in heaven or refrain from providing a clear response (“Don’t know/refused” category). This uncertainty is relatively low across most religious affiliations but is more pronounced among some groups like Jews (13.20%) and Atheists (3.50%).


Heaven_belief <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q35)) %>%  # Ensure q16 and q21 are not NA
  group_by(q16, q35) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q35)


Heaven_belief_selected <- select(Heaven_belief, q16, q35, Percentage)


Heaven_belief_wide <- pivot_wider(
  Heaven_belief_selected,
  names_from = q35,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Heaven_belief_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table_Heaven <- kable(Heaven_belief_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Belief in Heaven" = 3, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table_Heaven
Belief in Heaven
Religion Don’t know/refused (VOL.) No Other (VOL.) Yes
Agnostic (not sure if there is a God) 11.743341 70.096852 2.663438 15.49637
Atheist (do not believe in God) 3.495146 85.242718 0.776699 10.48544
Buddhist 7.542579 59.854015 2.919708 29.68370
Christian (VOL) 8.561644 14.554794 5.308219 71.57534
Don’t know/Refused (VOL) 29.600000 38.800000 3.200000 28.40000
Hindu 10.894942 37.743191 3.112840 48.24903
Jehovah’s Witness (VOL) 3.755869 39.906103 9.389671 46.94836
Jewish (Judaism) 13.196481 52.346041 1.612903 32.84457
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 1.721170 2.409639 1.032702 94.83649
Muslim (Islam) 1.724138 12.068965 2.586207 83.62069
Nothing in particular 10.925277 41.111411 2.562719 45.40059
Orthodox (Greek, Russian, or some other orthodox church) 7.162534 17.630854 3.305785 71.90083
Protestant 4.860241 8.592601 4.587806 81.95935
Roman Catholic 5.654281 9.432087 1.851622 83.06201
Unitarian (Universalist) (VOL) 8.441558 72.727273 3.246753 15.58442



Hell_belief <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q36)) %>%  # Ensure q16 and q21 are not NA
  group_by(q16, q36) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q36)


Hell_belief_selected <- select(Hell_belief, q16, q36, Percentage)


Hell_belief_wide <- pivot_wider(
  Hell_belief_selected,
  names_from = q36,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Hell_belief_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table_Hell <- kable(Hell_belief_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Belief in Hell" = 3, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table_Hell
Belief in Hell
Religion Don’t know/refused (VOL.) No Other (VOL.) Yes
Agnostic (not sure if there is a God) 9.685230 78.32930 2.1791768 9.806295
Atheist (do not believe in God) 2.912621 87.37864 0.9708738 8.737864
Buddhist 7.055961 70.31630 2.1897810 20.437956
Christian (VOL) 10.102740 27.91096 4.4520548 57.534247
Don’t know/Refused (VOL) 28.800000 49.20000 4.4000000 17.600000
Hindu 11.673152 50.19455 3.5019455 34.630350
Jehovah’s Witness (VOL) 1.408451 87.79343 1.8779343 8.920188
Jewish (Judaism) 9.237537 72.87390 0.8797654 17.008798
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 5.163511 29.43201 8.7779690 56.626506
Muslim (Islam) 3.448276 12.93103 5.1724138 78.448276
Nothing in particular 9.630429 55.48961 2.1850553 32.694902
Orthodox (Greek, Russian, or some other orthodox church) 12.672176 30.30303 3.5812672 53.443526
Protestant 7.769847 18.60186 3.2801177 70.348172
Roman Catholic 10.190133 27.22754 2.8209271 59.761402
Unitarian (Universalist) (VOL) 3.896104 88.96104 1.9480519 5.194805


Belief in Hell Across Different Religious Affiliations:

The dataset reveals a spectrum of beliefs regarding the concept of hell among individuals from various religious backgrounds:

  • Strong Belief: A substantial proportion of respondents, particularly from Christian denominations like Jehovah’s Witnesses (8.92%) and Mormons (56.63%), express a strong belief in hell. This belief is also prevalent among Muslims (78.45%) and certain Protestant groups (70.35%).

  • Moderate Belief: Some respondents demonstrate a moderate level of belief in hell, including individuals from Orthodox Christian traditions (53.44%) and Roman Catholics (59.76%).

  • Low Belief: Certain religious affiliations exhibit lower levels of belief in hell compared to others. For instance, Buddhists (20.44%) and individuals identifying with “Nothing in particular” (32.69%) show lower rates of belief in hell.

  • Uncertainty: A minority of respondents express uncertainty about their belief in hell or decline to provide a clear response (“Don’t know/refused” category). This uncertainty is relatively low across most religious affiliations but is more pronounced among some groups like Jews (9.24%) and Atheists (2.91%).


Combined_Heaven_Hell_wide = bind_cols (Heaven_belief_wide$Religion , Heaven_belief_wide$Yes , Hell_belief_wide$Yes)
## New names:
## • `` -> `...1`
## • `` -> `...2`
## • `` -> `...3`
colnames(Combined_Heaven_Hell_wide)[1] <- "Religion"
colnames(Combined_Heaven_Hell_wide)[2] <- "Heaven"
colnames(Combined_Heaven_Hell_wide)[3] <- "Hell"


# Reshape the data to a long format
long_data <- pivot_longer(
  Combined_Heaven_Hell_wide,
  cols = c("Heaven", "Hell"),
  names_to = "Belief",
  values_to = "Percentage"
)

# Create the bar plot
p <- ggplot(long_data, aes(x = Religion, y = Percentage, fill = Belief)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.7)) +
  labs(title = "Percentage of People Believing in Heaven and Hell by Religion",
       x = "Religion",
       y = "Percentage",
       fill = "Belief") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1),
        legend.position = "bottom")

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 700)

# Show the interactive plot in your default browser

interactive_plot


Miracles and the Supernatural


Belief in the Occurrence of Miracles Today:

The survey data provides insights into the beliefs regarding the occurrence of miracles in contemporary times compared to ancient eras among individuals from various religious backgrounds:

  • Strong Belief: A significant proportion of respondents from the Mormon Church (LDS) (79.17%), Protestant denominations (53.26%), and certain Christian denominations (52.05% to 46.80%) express strong agreement that miracles still occur today, akin to ancient times. This belief is notably high among Mormons, indicating a firm conviction in the continued manifestation of miracles.

  • Moderate Belief: Some respondents, particularly from Orthodox Christian traditions (41.87%), Islam (39.66%), and Hinduism (24.12%), express a moderate level of agreement with the notion that miracles still happen today. While not as pronounced as in the aforementioned groups, this belief remains notable within these religious affiliations.

  • Uncertainty: A portion of respondents either express uncertainty about the occurrence of miracles in contemporary times or decline to provide a definitive stance (“Don’t know/refused” category). This uncertainty varies across religious affiliations but is particularly notable among Atheists (61.75%) and individuals identifying with “Nothing in particular” (17.80%).

  • Disagreement: Certain respondents, including Atheists, Agnostics, and individuals from Jewish, Unitarian Universalist, and certain Christian denominations, express either complete disagreement or a majority disagreement with the idea that miracles still occur today as they did in ancient times.


Miracle_belief <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q39a)) %>%  # Ensure q16 and q39b are not NA
  group_by(q16, q39a) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q39a)


Miracle_belief_selected <- select(Miracle_belief, q16, q39a, Percentage)


Miracle_belief_wide <- pivot_wider(
  Miracle_belief_selected,
  names_from = q39a,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Miracle_belief_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table_Miracle <- kable(Miracle_belief_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Question: Miracles still occur today as in ancient times" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table_Miracle
Question: Miracles still occur today as in ancient times
Religion Completely agree Completely disagree Don’t know/refused (VOL.) Mostly agree Mostly disagree
Agnostic (not sure if there is a God) 13.075060 36.3196126 4.6004843 21.428571 24.576271
Atheist (do not believe in God) 9.514563 61.7475728 3.8834951 9.126214 15.728155
Buddhist 30.170316 16.7883212 5.3527981 28.953771 18.734793
Christian (VOL) 52.054794 5.6506849 5.9931507 28.938356 7.363014
Don’t know/Refused (VOL) 22.400000 16.8000000 22.4000000 24.000000 14.400000
Hindu 24.124514 12.4513619 4.6692607 43.579766 15.175097
Jehovah’s Witness (VOL) 14.084507 46.4788732 5.1643192 15.492958 18.779343
Jewish (Judaism) 18.768328 24.6334311 6.1583578 29.618768 20.821114
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 79.173838 0.8605852 0.3442341 17.383821 2.237522
Muslim (Islam) 39.655172 12.9310345 6.0344828 27.586207 13.793103
Nothing in particular 27.569463 17.8041543 4.5049906 32.560022 17.561370
Orthodox (Greek, Russian, or some other orthodox church) 41.873278 8.5399449 2.7548209 36.639119 10.192837
Protestant 53.261047 3.8304364 2.7352476 32.163679 8.009590
Roman Catholic 46.800050 4.2127501 2.9824779 36.858457 9.146266
Unitarian (Universalist) (VOL) 14.935065 23.3766234 5.1948052 36.363636 20.129870


Similarly, about two-thirds of U.S. adults (68%) believe in the activity of angels and demons in the world. This belief is especially common among members of Christian traditions, including approximately nine-in-ten members of evangelical Protestant churches, Jehovah’s Witnesses, and Mormons.


DEMON_belief <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q39b)) %>%  # Ensure q16 and q21 are not NA
  group_by(q16, q39b) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q39b)


DEMON_belief_selected <- select(DEMON_belief, q16, q39b, Percentage)


DEMON_belief_wide <- pivot_wider(
  DEMON_belief_selected,
  names_from = q39b,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(DEMON_belief_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table_Demon <- kable(DEMON_belief_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Question: Angels and demons are active in the world" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table_Demon
Question: Angels and demons are active in the world
Religion Completely agree Completely disagree Don’t know/refused (VOL.) Mostly agree Mostly disagree
Agnostic (not sure if there is a God) 6.416465 55.690073 3.3898305 11.016949 23.4866828
Atheist (do not believe in God) 5.242718 76.893204 3.3009709 6.407767 8.1553398
Buddhist 12.165450 35.766423 6.3260341 22.627737 23.1143552
Christian (VOL) 44.863014 8.219178 9.7602740 27.568493 9.5890411
Don’t know/Refused (VOL) 16.800000 28.000000 25.2000000 13.600000 16.4000000
Hindu 15.175097 35.019455 7.7821012 19.455253 22.5680934
Jehovah’s Witness (VOL) 78.873239 2.816901 0.9389671 16.901408 0.4694836
Jewish (Judaism) 7.478006 54.692082 7.0381232 10.703812 20.0879765
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 58.864027 3.270224 3.7865749 29.948365 4.1308090
Muslim (Islam) 45.689655 6.034483 8.6206897 31.034483 8.6206897
Nothing in particular 19.800378 29.646614 6.4472619 24.089560 20.0161856
Orthodox (Greek, Russian, or some other orthodox church) 32.231405 13.774105 5.5096419 32.231405 16.2534435
Protestant 48.329973 7.350297 4.6749850 29.014330 10.6304146
Roman Catholic 33.962968 10.289549 5.7909780 34.708587 15.2479185
Unitarian (Universalist) (VOL) 5.844156 52.597403 5.8441558 10.389610 25.3246753


In contrast, belief in the activity of angels and demons is less common among Buddhists and Hindus, as well as among Jews. While relatively few atheists and agnostics hold this belief.


Religious Practices


Worship Attendance


The data illustrates diverse patterns of attendance across different religious groups. For instance, some groups show higher rates of frequent attendance, such as Jehovah’s Witnesses and Mormons, with a significant proportion attending religious services several times a day. Within the Christian category, there’s notable variation in attendance habits. For example, while a considerable portion of Roman Catholics attend services a few times a week or more, Protestant attendees tend to spread more evenly across different levels of attendance frequency.


Worship_frequency <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q41)) %>%  # Ensure q16 and q41 are not NA
  group_by(q16, q41) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q41)


Worship_frequency_selected <- select(Worship_frequency, q16, q41, Percentage)


Worship_frequency_wide <- pivot_wider(
  Worship_frequency_selected,
  names_from = q41,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Worship_frequency_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Worship_frequency_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Attendance at Religious Services" = 7, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Attendance at Religious Services
Religion A few times a month A few times a week Don’t know/Refused (VOL.) Never Once a day Once a week Seldom Several times a day
Agnostic (not sure if there is a God) 6.537530 6.295400 0.3631961 44.4309927 3.631961 1.8159806 30.871671 6.053269
Atheist (do not believe in God) 1.553398 2.330097 2.1359223 79.2233010 2.330097 1.5533981 8.737864 2.135922
Buddhist 8.272506 10.948905 1.4598540 15.3284672 19.221411 1.9464720 15.328467 27.493917
Christian (VOL) 3.767123 14.212329 6.6780822 2.5684932 18.664384 1.3698630 7.191781 45.547945
Don’t know/Refused (VOL) 4.400000 7.600000 20.0000000 19.2000000 9.200000 1.2000000 20.800000 17.600000
Hindu 5.058366 10.894942 1.9455253 4.6692607 36.186770 3.1128405 12.840467 25.291829
Jehovah’s Witness (VOL) 1.877934 5.164319 0.4694836 0.4694836 9.859155 0.4694836 1.408451 80.281690
Jewish (Judaism) 8.357771 13.196481 3.5190616 18.0351906 12.023460 4.5454545 27.712610 12.609971
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 2.753873 6.884682 0.6884682 0.3442341 16.006885 1.2048193 4.130809 67.986231
Muslim (Islam) 0.862069 6.034483 0.8620690 7.7586207 5.172414 2.5862069 8.620690 68.103448
Nothing in particular 7.661181 11.788508 2.1041273 24.2514162 11.087132 2.1580793 24.925816 16.023739
Orthodox (Greek, Russian, or some other orthodox church) 5.234160 15.151515 1.9283747 4.1322314 26.997245 3.0303030 11.570248 31.955923
Protestant 4.380755 14.166621 1.3839699 1.4602517 21.500572 2.1631341 6.195172 48.749523
Roman Catholic 6.288058 16.751584 1.1805642 2.3984093 25.599602 3.6908165 9.282963 34.808003
Unitarian (Universalist) (VOL) 4.545454 11.038961 3.2467532 22.0779221 14.935065 5.1948052 18.831169 20.129870


Atheists and agnostics exhibit lower rates of religious service attendance compared to religious groups. The majority of respondents in these categories report never attending religious services, with atheists (79.2%) and agnostics (44.4%) being the highest in this regard.Those who identify as having “nothing in particular” also show varied attendance patterns, with a significant proportion reporting infrequent or no attendance. Specifically, 24.3% report never attending religious services..Minority religious groups such as Buddhists, Hindus, Muslims, and Jews display diverse attendance patterns, with some members attending services frequently while others rarely do. For example, among Muslims, 68.1% report attending services several times a day, while among Jews, 27.7% attend services a few times a week or more.


Religious Upbringing of Children


Overall, nearly two-thirds of adults (63%) who have children under age 18 living at home say they pray or read Scripture with their children. Mormons (91%) are especially likely to do this. Roughly eight-in-ten members of protestan (81%) and historically black (77%) churches also pray or read Scripture with their children. Jews (41%), Buddhists (37%) and the unaffiliated (31%) are much less likely to pray or read Scripture with their children compared with members of many other religious traditions. But there are major differences within the unaffiliated group; a majority of the religious unaffiliated (52%) pray or read Scripture with their children, compared with only 16% of the secular unaffiliated, 19% of agnostics and 8% of atheists. Similar patterns are seen in parents’ decisions about sending their children to Sunday school or other religious education programs. Six-in-ten Americans with children under age 18 living at home arrange for them to attend such programs. Mormons (90%) stand out for their propensityto enroll their children in religious education, followed by members of evangelical (79%) and historically black (77%) churches. More than a third of the unaffiliated (35%) send their children to religious education programs, including a quarter of atheists (24%) and about half of the religious unaffiliated (49%). Among parents with children under age 18 living in their homes, 15% home-school their children or send them to a religious school instead of a public school. Jews (27%) and Orthodox Christians (30%) are most likely to do this.


Upbringing_children <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q55a)) %>%  # Ensure q16 and q41 are not NA
  group_by(q16, q55a) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q55a)


Upbringing_children_selected <- select(Upbringing_children, q16, q55a, Percentage)


Upbringing_children_wide <- pivot_wider(
  Upbringing_children_selected,
  names_from = q55a,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Upbringing_children_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table_1 <- kable(Upbringing_children_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Send any of your children to Sunday school" = 2, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table_1
Send any of your children to Sunday school
Religion No Yes Don’t know/Refused (VOL.)
Agnostic (not sure if there is a God) 81.025641 18.974359 0.0000000
Atheist (do not believe in God) 90.163934 7.377049 2.4590164
Buddhist 65.833333 34.166667 0.0000000
Christian (VOL) 28.947368 67.894737 3.1578947
Don’t know/Refused (VOL) 54.929578 36.619718 8.4507042
Hindu 34.375000 64.062500 1.5625000
Jehovah’s Witness (VOL) 13.888889 86.111111 0.0000000
Jewish (Judaism) 59.880240 40.119760 0.0000000
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 8.433735 91.566265 0.0000000
Muslim (Islam) 44.642857 55.357143 0.0000000
Nothing in particular 65.822785 33.502110 0.6751055
Orthodox (Greek, Russian, or some other orthodox church) 45.283019 54.716981 0.0000000
Protestant 25.134823 74.345146 0.5200308
Roman Catholic 36.720209 62.831528 0.4482630
Unitarian (Universalist) (VOL) 61.363636 38.636364 0.0000000


Upbringing_children_2 <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q55b)) %>%  # Ensure q16 and q41 are not NA
  group_by(q16, q55b) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q55b)


Upbringing_children_2_selected <- select(Upbringing_children_2, q16, q55b, Percentage)


Upbringing_children_2_wide <- pivot_wider(
  Upbringing_children_2_selected,
  names_from = q55b,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Upbringing_children_2_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table_2 <- kable(Upbringing_children_2_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Pray or read the Scripture with your child" = 2, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table_2
Pray or read the Scripture with your child
Religion No Yes Don’t know/Refused (VOL.)
Agnostic (not sure if there is a God) 68.205128 31.79487 0.0000000
Atheist (do not believe in God) 72.950820 23.77049 3.2786885
Buddhist 72.500000 27.50000 0.0000000
Christian (VOL) 40.526316 57.36842 2.1052632
Don’t know/Refused (VOL) 57.746479 35.21127 7.0422535
Hindu 75.781250 21.87500 2.3437500
Jehovah’s Witness (VOL) 63.888889 34.72222 1.3888889
Jewish (Judaism) 43.113773 56.88623 0.0000000
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 8.835341 91.16466 0.0000000
Muslim (Islam) 58.928571 41.07143 0.0000000
Nothing in particular 62.278481 37.21519 0.5063291
Orthodox (Greek, Russian, or some other orthodox church) 39.622642 60.37736 0.0000000
Protestant 24.229584 75.28891 0.4815100
Roman Catholic 43.332088 56.10758 0.5603287
Unitarian (Universalist) (VOL) 36.363636 63.63636 0.0000000


Upbringing_children_3 <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q55c)) %>%  # Ensure q16 and q41 are not NA
  group_by(q16, q55c) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q55c)


Upbringing_children_3_selected <- select(Upbringing_children_3, q16, q55c, Percentage)


Upbringing_children_3_wide <- pivot_wider(
  Upbringing_children_3_selected,
  names_from = q55c,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Upbringing_children_3_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table_3 <- kable(Upbringing_children_3_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Send your child/childern to religious school instead of a public school" = 2, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table_3
Send your child/childern to religious school instead of a public school
Religion Don’t know/Refused (VOL.) No Yes
Agnostic (not sure if there is a God) 0.5128205 90.76923 8.717949
Atheist (do not believe in God) 2.4590164 91.80328 5.737705
Buddhist 0.8333333 89.16667 10.000000
Christian (VOL) 2.1052632 81.57895 16.315790
Don’t know/Refused (VOL) 7.0422535 80.28169 12.676056
Hindu 1.5625000 93.75000 4.687500
Jehovah’s Witness (VOL) 1.3888889 84.72222 13.888889
Jewish (Judaism) 0.0000000 76.64671 23.353293
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 0.0000000 93.97590 6.024096
Muslim (Islam) 0.0000000 85.71429 14.285714
Nothing in particular 0.5907173 92.32068 7.088608
Orthodox (Greek, Russian, or some other orthodox church) 0.0000000 68.86792 31.132075
Protestant 0.8859784 83.82126 15.292758
Roman Catholic 0.7097497 77.54950 21.740755
Unitarian (Universalist) (VOL) 0.0000000 90.90909 9.090909


Combined_Upbringing_children_wide = bind_cols (Upbringing_children_wide$Religion , Upbringing_children_wide$Yes , Upbringing_children_2_wide$Yes , Upbringing_children_3_wide$Yes)
## New names:
## • `` -> `...1`
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
colnames(Combined_Upbringing_children_wide)[1] <- "Religion"
colnames(Combined_Upbringing_children_wide)[2] <- "Pray and read scripture"
colnames(Combined_Upbringing_children_wide)[3] <- "attend religious school on sunday"
colnames(Combined_Upbringing_children_wide)[4] <- "attend religious school instead of public school"


# Reshape the data to a long format
long_data <- pivot_longer(
  Combined_Upbringing_children_wide,
  cols = c("Pray and read scripture", "attend religious school on sunday","attend religious school instead of public school"),
  names_to = "Belief",
  values_to = "Percentage"
)

# Create the bar plot
p <- ggplot(long_data, aes(x = Religion, y = Percentage, fill = Belief)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.7)) +
  labs(title = "Percentage of People saying yes to the quesions",
       x = "Religion",
       y = "Percentage",
       fill = "Belief") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1),
        legend.position = "bottom")


# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 900)

# Show the interactive plot in your default browser

interactive_plot


Similar patterns are seen in parents’ decisions about sending their children to Sunday school or other religious education programs. Six-in-ten Americans with children under age 18 living at home arrange for them to attend such programs. Mormons (90%) stand out for their propensity to enroll their children in religious education. More than a third of the unaffiliated (35%) send their children to religious education programs, including a quarter of atheists (24%). Among parents with children under age 18 living in their homes, 15% home-school their children or send them to a religious school instead of a public school. Jews (27%) and Orthodox Christians (30%) are most likely to do this.


Spiritual Experiences


Spritual Peace and Wonder


A majority of Americans (52%) report experiencing a sense of spiritual peace and well-being at least once a week. High rates of weekly spiritual peace are observed among Jehovah’s Witnesses and Mormons (77% and 71%, respectively), Muslims (64%). Conversely, Jews (38%) and the unaffiliated (35%) are among the groups least likely to experience spiritual peace on a weekly basis.

In contrast, a smaller proportion of Americans (39%) report feeling a deep sense of wonder about the universe on a weekly basis. Notably, over half of Buddhists (57%) and Muslims (53%) report experiencing this deep sense of wonder weekly, along with nearly half of Jehovah’s Witnesses (49%).


Peace_Wonder <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q43a)) %>%  # Ensure q16 and q43a are not NA
  group_by(q16, q43a) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q43a)


Peace_Wonder_selected <- select(Peace_Wonder, q16, q43a, Percentage)


Peace_Wonder_wide <- pivot_wider(
  Peace_Wonder_selected,
  names_from = q43a,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Peace_Wonder_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Peace_Wonder_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "feel a deep sense of spiritual peace and well-being" = 5, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
feel a deep sense of spiritual peace and well-being
Religion At least once a week Don’t know/Refused (VOL.) Never Once or twice a month Seldom Several times a year
Agnostic (not sure if there is a God) 32.32446 3.510896 14.5278450 14.769976 20.217918 14.648910
Atheist (do not believe in God) 29.51456 6.213592 30.2912621 9.320388 15.145631 9.514563
Buddhist 57.66423 3.649635 4.6228710 14.841849 9.975669 9.245742
Christian (VOL) 56.67808 7.191781 3.9383562 11.301370 10.445206 10.445206
Don’t know/Refused (VOL) 40.40000 19.200000 11.6000000 7.200000 13.600000 8.000000
Hindu 46.69261 4.669261 8.1712062 7.392996 10.505837 22.568093
Jehovah’s Witness (VOL) 79.34272 2.816901 3.2863850 5.633803 2.816901 6.103286
Jewish (Judaism) 35.33724 6.011730 9.6774194 14.076246 21.114369 13.782991
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 74.01033 2.237522 0.5163511 11.187608 4.475043 7.573150
Muslim (Islam) 65.51724 3.448276 3.4482759 12.931035 7.758621 6.896552
Nothing in particular 37.25384 4.343135 13.2452118 12.274076 20.852441 12.031292
Orthodox (Greek, Russian, or some other orthodox church) 46.83196 3.581267 5.7851240 16.253443 12.121212 15.426997
Protestant 61.29788 3.220182 2.8932600 13.262137 8.483627 10.842914
Roman Catholic 48.72623 3.442277 4.7719647 15.558593 12.016901 15.484031
Unitarian (Universalist) (VOL) 54.54545 1.948052 5.8441558 18.181818 11.038961 8.441558


Peace_Wonder <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q43a)) %>%  # Ensure q16 and q43b are not NA
  group_by(q16, q43b) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q43b)


Peace_Wonder_selected <- select(Peace_Wonder, q16, q43b, Percentage)


Peace_Wonder_wide <- pivot_wider(
  Peace_Wonder_selected,
  names_from = q43b,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Peace_Wonder_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Peace_Wonder_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "feel a deep sense of wonder about the universe" = 5, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
feel a deep sense of wonder about the universe
Religion At least once a week Don’t know/Refused (VOL.) Never Once or twice a month Seldom Several times a year
Agnostic (not sure if there is a God) 47.82082 0.4842615 6.537530 16.828087 15.254237 13.075060
Atheist (do not believe in God) 39.80583 2.7184466 15.728155 13.203883 16.310680 12.233010
Buddhist 61.55718 2.9197080 7.299270 11.678832 7.542579 9.002433
Christian (VOL) 41.09589 6.8493151 12.500000 12.157534 14.897260 12.500000
Don’t know/Refused (VOL) 44.00000 16.8000000 8.800000 9.200000 14.400000 6.800000
Hindu 37.35409 3.5019455 7.782101 12.062257 14.396887 24.902724
Jehovah’s Witness (VOL) 52.58216 5.6338028 16.901408 9.389671 7.042254 8.450704
Jewish (Judaism) 39.14956 3.9589443 11.583578 12.903226 15.249267 17.155425
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 43.71773 3.4423408 8.950086 16.006885 13.941480 13.941480
Muslim (Islam) 54.31034 5.1724138 6.896552 12.931035 13.793103 6.896552
Nothing in particular 39.06124 3.0213110 11.141084 12.651740 19.773402 14.351227
Orthodox (Greek, Russian, or some other orthodox church) 36.91460 3.8567493 11.019284 13.223140 15.151515 19.834711
Protestant 41.02327 4.5769084 10.292595 14.139378 16.460524 13.507328
Roman Catholic 34.91985 3.8275134 10.960606 13.992792 19.572512 16.726730
Unitarian (Universalist) (VOL) 66.88312 1.9480519 2.597403 12.337662 7.792208 8.441558


While Mormons and protestant diverge from the general public on various religious beliefs and practices, they align closely with the broader population on this particular question. Approximately 41% of protestant, 43% of Mormons report feeling a deep sense of wonder about the universe on a weekly basis. This places them in close proximity to Jews (40%) and the unaffiliated (39%).

Interestingly, within the unaffiliated category, agnostics stand out as the subgroup most likely to frequently experience a sense of wonder, with 48% reporting weekly occurrences. This contrasts with the figures for atheists (37%), the religious unaffiliated (40%).


Is There More Than One Path to Salvation?


Quesion: My religion is the one true faith leading to eternal life, OR Many religions can lead to eternal life.

Faith_flexibility <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q40a)) %>%  # Ensure q16 and q43b are not NA
  group_by(q16, q40a) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q40a)


Faith_flexibility_selected <- select(Faith_flexibility, q16, q40a, Percentage)


Faith_flexibility_wide <- pivot_wider(
  Faith_flexibility_selected,
  names_from = q40a,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Faith_flexibility_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Faith_flexibility_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "is There More Than One Path to Salvation" = 3, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
is There More Than One Path to Salvation
Religion Don’t know/refused (VOL) Many religions can lead to eternal life - Second statement My religion is the one, true faith leading to eternal life - Neither/Both equally (VOL)
Buddhist 3.892944 85.88808 3.8929440 6.3260341
Christian (VOL) 8.047945 66.26712 23.4589041 2.2260274
Hindu 4.669261 89.49416 4.2801556 1.5564202
Jehovah’s Witness (VOL) 2.816901 14.55399 82.1596244 0.4694836
Jewish (Judaism) 6.158358 82.40469 3.5190616 7.9178886
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 1.549053 39.07057 56.6265060 2.7538726
Muslim (Islam) 10.344828 56.89655 29.3103448 3.4482759
Orthodox (Greek, Russian, or some other orthodox church) 4.958678 71.62534 20.1101928 3.3057851
Protestant 4.021141 67.88536 25.6906228 2.4028769
Roman Catholic 2.796073 81.91873 13.4211507 1.8640487
Unitarian (Universalist) (VOL) 3.246753 81.81818 0.6493506 14.2857143


# Assuming Combined_Heaven_Hell_wide has two columns: Religion, and Percentage with values for Heaven and Hell
# Inverting sign for "Hell" percentages
# Sample data frame
religions <- Faith_flexibility_wide$Religion
many_religions <- Faith_flexibility_wide$`Many religions can lead to eternal life - Second statement`
one_true_faith <- Faith_flexibility_wide$`My religion is the one, true faith leading to eternal life -`

df <- data.frame(
  Religion = factor(religions, levels = religions),
  `who_say_many_religions_can_lead_to_eternal_life` = many_religions,
  `who_say_my_religion_is_the_one_true_faith_leading_to_eternal_life` = -one_true_faith
)


# Sort the religions based on 'Many religions can lead to eternal life'
df_sorted <- df %>%
  arrange(desc(`who_say_many_religions_can_lead_to_eternal_life`))

# Update the factor levels of Religion to the new order
df_sorted$Religion <- factor(df_sorted$Religion, levels = df_sorted$Religion)

long_df <- pivot_longer(
  df_sorted,
  cols = c(`who_say_many_religions_can_lead_to_eternal_life`, `who_say_my_religion_is_the_one_true_faith_leading_to_eternal_life`),
  names_to = "Belief",
  values_to = "Percentage"
)

long_df <- long_df[order(long_df$Percentage, decreasing = TRUE),]

# Create the plot
p <- ggplot(long_df, aes(x = Religion, y = Percentage, fill = Belief)) +
  geom_bar(stat = "identity", position = "identity") +
  coord_flip() +
  scale_fill_manual(values = c("#FFA07A", "blue")) +
  labs(title = "Religious Exclusivity",
       x = "",
       y = "Percentage")+
  theme_minimal() +
  theme(legend.position = "right",
        
        axis.ticks.y = element_blank(),
        panel.grid = element_blank())


# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 500)

# Show the interactive plot in your default browser

interactive_plot



The majority of Americans with a religious affiliation believe that many religions can lead to eternal life, with seven-in-ten holding this view. This perspective is widespread across various religious traditions, including more than eight-in-ten Jews, Buddhists, Hindus, and Protestant, as well as nearly eight-in-ten Catholics. However 56% of Muslims, share this belief. Notably, among Mormons and Jehovah’s Witnesses, a majority assert that their religion is the sole path to eternal life.

How Strictly to Interpret the Faith?


Quesion: There is only ONE true way to interpret the teachings of my religion, OR There is MORE than one true way to interpret the teachings of my religion.


More than two-thirds of Americans with a religious affiliation (68%) believe in the possibility of multiple interpretations of their faith’s teachings. A majority of members of evangelical churches (64%) share this view, along with upwards of six-in-ten individuals from most other religious traditions. Notably, a significant proportion of Jews (89%) and Buddhists (90%) express the belief in multiple valid interpretations of their religion’s teachings. However, Mormons and Jehovah’s Witnesses differ on this point, with majorities from both groups (54% among Mormons, 77% among Jehovah’s Witnesses) asserting that there is only one true interpretation of their religion’s teachings.


Faith_flexibility <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q40b)) %>%  # Ensure q16 and q40b are not NA
  group_by(q16, q40b) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q40b)


Faith_flexibility_selected <- select(Faith_flexibility, q16, q40b, Percentage)


Faith_flexibility_wide <- pivot_wider(
  Faith_flexibility_selected,
  names_from = q40b,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Faith_flexibility_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Faith_flexibility_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Strictness of Interpretation" = 3, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Strictness of Interpretation
Religion Don’t know/refused (VOL) Neither/Both equally (VOL) There is MORE than one true way to interpret the teachings o There is only ONE true way to interpret the teachings of my
Buddhist 3.406326 0.4866180 90.99757 5.109489
Christian (VOL) 7.363014 2.7397260 64.72603 25.171233
Hindu 3.891051 1.1673152 84.82490 10.116732
Jehovah’s Witness (VOL) 4.225352 1.4084507 14.55399 79.812207
Jewish (Judaism) 3.519062 0.7331378 90.90909 4.838710
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 2.409639 1.5490534 39.75904 56.282272
Muslim (Islam) 6.896552 1.7241379 62.93103 28.448276
Orthodox (Greek, Russian, or some other orthodox church) 4.407713 1.1019284 67.49311 26.997245
Protestant 3.863129 1.1115349 64.05492 30.970414
Roman Catholic 3.380142 0.7704735 77.27103 18.578352
Unitarian (Universalist) (VOL) 1.298701 2.5974026 92.85714 3.246753


religions <- Faith_flexibility_wide$Religion
many_religions <- Faith_flexibility_wide$`There is MORE than one true way to interpret the teachings o`
one_true_faith <- Faith_flexibility_wide$`There is only ONE true way to interpret the teachings of my`

df <- data.frame(
  Religion = factor(religions, levels = religions),
  `There_is_MORE_than_one_true_way_to_interpret_the_teachings` = many_religions,
  `There_is_only_one_true_way_to_interpret_the_teachings` = -one_true_faith
)


# Sort the religions based on 'Many religions can lead to eternal life'
df_sorted <- df %>%
  arrange(desc(`There_is_MORE_than_one_true_way_to_interpret_the_teachings`))

# Update the factor levels of Religion to the new order
df_sorted$Religion <- factor(df_sorted$Religion, levels = df_sorted$Religion)

long_df <- pivot_longer(
  df_sorted,
  cols = c(`There_is_MORE_than_one_true_way_to_interpret_the_teachings`, `There_is_only_one_true_way_to_interpret_the_teachings`),
  names_to = "Belief",
  values_to = "Percentage"
)

long_df <- long_df[order(long_df$Percentage, decreasing = TRUE),]

# Create the plot
p <- ggplot(long_df, aes(x = Religion, y = Percentage, fill = Belief)) +
  geom_bar(stat = "identity", position = "identity") +
  coord_flip() +
  scale_fill_manual(values = c("#FFA07A", "blue")) +
  labs(title = "Religious Interpretablility",
       x = "",
       y = "Percentage")+
  theme_minimal() +
  theme(legend.position = "right",
        
        axis.ticks.y = element_blank(),
        panel.grid = element_blank())


# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 500)

# Show the interactive plot in your default browser

interactive_plot


Beliefs About Morality


Quesion: There are clear and absolute standards for what is right and wrong.


Right_Wrong <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q10b)) %>%  # Ensure q16 and q10b are not NA
  group_by(q16, q10b) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q10b)


Right_Wrong_selected <- select(Right_Wrong, q16, q10b, Percentage)


Right_Wrong_wide <- pivot_wider(
  Right_Wrong_selected,
  names_from = q10b,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Right_Wrong_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Right_Wrong_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Absolute Standards of Right and Wrong" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Absolute Standards of Right and Wrong
Religion Completely agree Completely disagree Don’t know/Refused (VOL.) Mostly agree Mostly disagree
Agnostic (not sure if there is a God) 17.79661 12.469734 2.058111 40.43584 27.239709
Atheist (do not believe in God) 19.02913 14.563107 2.330097 38.05825 26.019417
Buddhist 13.38200 20.924574 3.163017 35.27981 27.250608
Christian (VOL) 38.69863 7.020548 3.938356 37.15753 13.184931
Don’t know/Refused (VOL) 26.80000 13.600000 8.800000 29.60000 21.200000
Hindu 20.62257 9.338521 6.225681 43.19066 20.622568
Jehovah’s Witness (VOL) 58.21596 4.225352 2.816901 26.76056 7.981221
Jewish (Judaism) 18.03519 9.824047 2.492669 44.28152 25.366569
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 45.78313 3.098107 1.549053 41.65232 7.917384
Muslim (Islam) 33.62069 7.758621 5.172414 36.20690 17.241379
Nothing in particular 29.24197 9.873213 2.346911 38.89938 19.638522
Orthodox (Greek, Russian, or some other orthodox church) 31.95592 7.988981 4.683196 40.22039 15.151515
Protestant 42.73961 4.811203 2.157685 38.13545 12.156051
Roman Catholic 36.47322 5.778551 2.423263 42.15235 13.172611
Unitarian (Universalist) (VOL) 11.03896 14.285714 4.545454 37.01299 33.116883


While most Americans believe in absolute standards of right and wrong, there are some differences among groups. For example, Buddhists, atheists, and agnostics are somewhat less likely to believe in absolute standards compared to other religious groups or the religiously unaffiliated as a whole. This suggests that while there’s a general trend toward believing in universal moral principles, individual beliefs can vary based on religious background or lack thereof.


Conclusion


The analysis of religious beliefs and practices across a diverse array of faiths and those without religious affiliation reveals significant insights into how religion—or the absence of it—shapes individuals’ worldviews, ethical standards, and daily practices.

Religious Affiliations: For those with religious affiliations, religion typically serves as a foundational element in their lives, deeply influencing their morals, behaviors, and outlooks. These individuals often view their religious tenets as not just beliefs but as integral truths that guide their understanding of the world, their behavior, and their expectations of the afterlife. They tend to participate more actively in community and religious rituals, which reinforces their faith and fosters a sense of belonging and identity. The belief in divine beings, miracles, and an active spiritual realm is prevalent, reflecting a worldview where the divine intimately interacts with the world.

Non-religious Individuals (Atheists, Agnostics, Unaffiliated): In contrast, those without religious affiliations often embrace a worldview grounded in secularism or humanism. This group tends to place less importance on structured beliefs and shows a higher propensity for skepticism towards supernatural claims and absolute truths. However, this does not imply a lack of ethical or moral consideration; many non-religious individuals still exhibit strong moral convictions and a sense of wonder about the universe, which they might attribute to philosophical or humanistic insights rather than spiritual or religious beliefs. Importantly, their engagement with spiritual practices, while less frequent, often occurs in a context that values cultural heritage or personal exploration over religious duty.

Shared Human Experience: Despite these differences, both groups share fundamental human experiences and emotions, such as the quest for meaning, the experience of awe, and the need for ethical guidelines. Both religious and non-religious individuals seek peace, purpose, and explanations for the complex world around them, albeit through different lenses.

Conclusion: This analysis suggests that while religious beliefs significantly shape one’s worldview and daily practices, underlying human experiences such as ethical dilemmas, spiritual peace, and existential wonder are universal. These findings indicate that the essence of human experience crosses the boundaries of religious and secular divides, pointing to a shared search for understanding and meaning that transcends specific belief systems. Thus, the dialogue between individuals of varying religious and non-religious backgrounds is not only possible but essential for a comprehensive understanding of the human condition.


Chapter 2: Social and Political Views


While religion might not always be seen as the main influence on social and political views for most Americans, the Landscape Survey reveals strong connections between religious affiliation, beliefs, and societal attitudes. This suggests that religion might have a significant, albeit indirect, role in shaping people’s perspectives more than they realize.

This chapter delves into the social and political stances of different religious groups. When possible, it breaks down these traditions further based on key measures of religious commitment, like how often someone attends worship services or the importance they place on religion in their lives. The analysis reveals that religious divisions often align with political fault lines, but also cut across them.

Despite the diversity of religious beliefs and practices in the U.S., there’s widespread agreement across most faiths about the positive impact of religion in society. Many Americans reject the idea that religion causes more problems than it solves. Moreover, most religious individuals don’t see a conflict between their devoutness and living in a modern society.


Religion and Society


Religion and Societal Problems


Quesion: Religion causes more problems in society than it solves.


  • Strong Agreement: Atheists and agnostics tend to strongly agree with the notion that religion causes more harm than good. This perspective likely stems from a belief in secularism and skepticism toward religious institutions’ influence on societal affairs.

  • Varied Perspectives: Other religious groups exhibit more diverse views. For example, Mormons and Protestants largely disagree with the statement, indicating a belief in the positive contributions of religion to society. Conversely, Buddhists, Hindus, and Jews show mixed sentiments, with a significant portion expressing agreement or uncertainty.

  • Neutral or Uncertain Stance: Some respondents, particularly those who volunteered as “Don’t know/Refused,” refrain from taking a definitive position on the matter. This could indicate a lack of clarity or hesitation in expressing a viewpoint.

Anti_religious_belief <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q39c)) %>%  # Ensure q16 and q39c are not NA
  group_by(q16, q39c) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q39c)


Anti_religious_belief_selected <- select(Anti_religious_belief, q16, q39c, Percentage)


Anti_religious_belief_wide <- pivot_wider(
  Anti_religious_belief_selected,
  names_from = q39c,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Anti_religious_belief_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Anti_religious_belief_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Question: Religion causes more problems in society than it solves" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Question: Religion causes more problems in society than it solves
Religion Completely agree Completely disagree Don’t know/refused (VOL.) Mostly agree Mostly disagree
Agnostic (not sure if there is a God) 40.193705 6.174334 2.058111 32.687651 18.88620
Atheist (do not believe in God) 52.427185 5.048544 2.912621 26.990291 12.62136
Buddhist 30.900243 9.002433 6.082725 29.683698 24.33090
Christian (VOL) 15.239726 32.191781 7.705480 18.835616 26.02740
Don’t know/Refused (VOL) 27.200000 11.200000 23.600000 22.400000 15.60000
Hindu 26.848249 15.175097 3.501946 32.684825 21.78988
Jehovah’s Witness (VOL) 31.924883 22.535211 8.450704 23.474178 13.61502
Jewish (Judaism) 22.873900 15.395894 5.718475 28.445748 27.56598
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 3.270224 55.421687 1.893287 9.122203 30.29260
Muslim (Islam) 10.344828 46.551724 3.448276 18.103448 21.55172
Nothing in particular 26.975991 15.376315 5.179390 28.675479 23.79282
Orthodox (Greek, Russian, or some other orthodox church) 13.498623 29.476584 4.132231 21.763085 31.12948
Protestant 8.189397 43.736719 3.857680 15.872065 28.34414
Roman Catholic 11.494967 33.702001 3.541693 19.659500 31.60184
Unitarian (Universalist) (VOL) 27.922078 6.493506 4.545454 33.116883 27.92208


Conclusion:

The data reflects the complexity of attitudes toward religion’s societal impact, highlighting contrasting perspectives among different religious affiliations. While some groups strongly believe in religion’s detrimental effects, others emphasize its positive influence. Understanding these varied viewpoints is essential for fostering dialogue and addressing societal challenges related to religion’s role in contemporary life.


Exploring Conflicts in Modern Living


Peaceful_living <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q46)) %>%  # Ensure q16 and q41 are not NA
  group_by(q16, q46) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q46)


Peaceful_living_selected <- select(Peaceful_living, q16, q46, Percentage)


Peaceful_living_wide <- pivot_wider(
  Peaceful_living_selected,
  names_from = q46,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Peaceful_living_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Peaceful_living_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "there is natural conflict between being a devout religious person and living in a modern society," = 2, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
there is natural conflict between being a devout religious person and living in a modern society,
Religion Don’t know/refused (VOL) No, don’t think so Yes, there is conflict
Buddhist 4.866180 69.34307 25.79075
Christian (VOL) 7.534247 54.96575 37.50000
Hindu 7.003891 62.64591 30.35019
Jehovah’s Witness (VOL) 9.859155 30.51643 59.62441
Jewish (Judaism) 6.011730 64.22287 29.76540
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 3.442341 61.61790 34.93976
Muslim (Islam) 5.172414 59.48276 35.34483
Orthodox (Greek, Russian, or some other orthodox church) 6.611570 60.60606 32.78237
Protestant 6.276903 51.89887 41.82422
Roman Catholic 5.231763 61.74972 33.01852
Unitarian (Universalist) (VOL) 4.545454 72.72727 22.72727


Among various religious groups, there’s a range of perspectives: The majority of Buddhists (69.3%), Hindus (62.6%), and Jews (64.2%) don’t perceive a conflict. Conversely, Jehovah’s Witnesses (59.6%), Protestants (41.8%), and Christians in general (37.5%) are more likely to see a conflict. Muslims (35.3%) and Orthodox Christians (32.8%) also lean towards perceiving a conflict. Overall, while there’s diversity in opinions, around a third to a half of respondents across different religious affiliations see a natural conflict between devout religious practice and living in a modern society.

Peaceful_living_non <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q47)) %>%  # Ensure q16 and q41 are not NA
  group_by(q16, q47) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q47)


Peaceful_living_non_selected <- select(Peaceful_living_non, q16, q47, Percentage)


Peaceful_living_non_wide <- pivot_wider(
  Peaceful_living_non_selected,
  names_from = q47,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Peaceful_living_non_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Peaceful_living_non_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "there is a natural conflict between being a non-religious person and living in a society where most people are religious," = 2, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
there is a natural conflict between being a non-religious person and living in a society where most people are religious,
Religion Don’t know/refused (VOL) No, don’t think so Yes, there is conflict
Agnostic (not sure if there is a God) 4.358353 57.26392 38.37772
Atheist (do not believe in God) 4.660194 52.23301 43.10680
Don’t know/Refused (VOL) 27.600000 51.20000 21.20000
Nothing in particular 6.123550 64.31076 29.56569


Agnostics (38.4%) and atheists (43.1%) are more likely to perceive a conflict. Those with no religious affiliation, such as “nothing in particular,” also show a similar trend, with 29.6% perceiving a conflict. However, a majority of respondents in these categories (57.3% for agnostics, 52.2% for atheists, and 64.3% for those with no particular affiliation) don’t perceive such a conflict. Notably, a significant proportion of respondents who refused to answer or didn’t know expressed uncertainty (27.6%) or didn’t perceive a conflict (51.2%). Overall, while a notable portion of non-religious individuals perceive a conflict between their beliefs and a predominantly religious society, the majority across these categories do not share this perception.


Satisfaction


First I want to go through all quesions about the different aspects of satisfaction.


Quesion:Are you very satisfied, somewhat satisfied, somewhat DISsatisfied or very DISsatisfied? (Your standard of living – what you can buy or do)

Personal_satisfaction <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q3a)) %>%  # Ensure q16 and q3a are not NA
  group_by(q16, q3a) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q3a)


Personal_satisfaction_selected <- select(Personal_satisfaction, q16, q3a, Percentage)


Personal_satisfaction_wide <- pivot_wider(
  Personal_satisfaction_selected,
  names_from = q3a,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Personal_satisfaction_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Personal_satisfaction_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Personal Life Satisfaction" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

table
Personal Life Satisfaction
Religion Don’t know/Refused (VOL.) Somewhat dissatisfied Somewhat satisfied Very dissatisfied Very satisfied
Agnostic (not sure if there is a God) 0.9685230 11.864407 38.37772 5.690073 43.09927
Atheist (do not believe in God) 1.3592233 9.514563 39.02913 6.796117 43.30097
Buddhist 0.7299270 10.948905 41.36253 5.109489 41.84915
Christian (VOL) 2.5684932 11.986301 41.43836 9.246575 34.76027
Don’t know/Refused (VOL) 4.0000000 12.400000 37.20000 6.000000 40.40000
Hindu 0.0000000 4.669261 43.96887 5.058366 46.30350
Jehovah’s Witness (VOL) 2.8169014 13.615023 40.84507 10.328639 32.39437
Jewish (Judaism) 1.1730205 8.944282 36.21701 4.252199 49.41349
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 0.5163511 10.327022 36.14458 4.647160 48.36489
Muslim (Islam) 0.8620690 8.620690 44.82759 7.758621 37.93103
Nothing in particular 1.2139196 13.002428 41.40815 8.740221 35.63528
Orthodox (Greek, Russian, or some other orthodox church) 2.7548209 12.947658 40.77135 6.060606 37.46556
Protestant 1.2423037 11.464066 38.34251 7.181387 41.76974
Roman Catholic 1.3669691 11.905058 39.67938 6.648440 40.40015
Unitarian (Universalist) (VOL) 1.9480519 9.090909 38.31169 3.896104 46.75325


Quesion: Are you very satisfied, somewhat satisfied, somewhat DISsatisfied or very DISsatisfied? (With your family life)

family_life_satisfaction <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q3b)) %>%  # Ensure q16 and q3a are not NA
  group_by(q16, q3b) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q3b)


family_life_satisfaction_selected <- select(family_life_satisfaction, q16, q3b, Percentage)


family_life_satisfaction_wide <- pivot_wider(
  family_life_satisfaction_selected,
  names_from = q3b,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(family_life_satisfaction_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(family_life_satisfaction_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Family Life Satisfaction" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

table
Family Life Satisfaction
Religion Don’t know/Refused (VOL.) Somewhat dissatisfied Somewhat satisfied Very dissatisfied Very satisfied
Agnostic (not sure if there is a God) 1.5738499 3.389830 22.39709 1.8159806 70.82324
Atheist (do not believe in God) 4.2718447 2.524272 22.33010 1.9417476 68.93204
Buddhist 1.2165450 2.433090 22.14112 1.4598540 72.74939
Christian (VOL) 4.1095890 3.424657 18.15068 2.3972603 71.91781
Don’t know/Refused (VOL) 8.0000000 2.400000 22.00000 2.4000000 65.20000
Hindu 1.9455253 2.723735 17.12062 1.5564202 76.65370
Jehovah’s Witness (VOL) 1.8779343 6.572770 21.12676 1.8779343 68.54460
Jewish (Judaism) 2.7859238 3.519062 16.42229 1.9061584 75.36657
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 0.8605852 2.925990 13.42513 0.3442341 82.44406
Muslim (Islam) 0.8620690 2.586207 20.68966 3.4482759 72.41379
Nothing in particular 2.4008632 3.345023 20.36687 2.3738872 71.51335
Orthodox (Greek, Russian, or some other orthodox church) 2.4793388 3.856749 18.73278 3.0303030 71.90083
Protestant 1.9996731 3.100311 17.29962 1.7326868 75.86771
Roman Catholic 1.5658009 3.193737 15.55859 1.5906549 78.09121
Unitarian (Universalist) (VOL) 3.8961039 0.000000 12.98701 0.6493506 82.46753


Quesion:Are you very satisfied, somewhat satisfied, somewhat DISsatisfied or very DISsatisfied? (With the way the political system is working in this country)

Standard_of_living_satisfaction <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q3c)) %>%  # Ensure q16 and q3a are not NA
  group_by(q16, q3c) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q3c)


Standard_of_living_satisfaction_selected <- select(Standard_of_living_satisfaction, q16, q3c, Percentage)


Standard_of_living_satisfaction_wide <- pivot_wider(
  Standard_of_living_satisfaction_selected,
  names_from = q3c,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Standard_of_living_satisfaction_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Standard_of_living_satisfaction_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Standard of Life Satisfaction" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

table
Standard of Life Satisfaction
Religion Don’t know/Refused (VOL.) Somewhat dissatisfied Somewhat satisfied Very dissatisfied Very satisfied
Agnostic (not sure if there is a God) 1.937046 26.99758 12.590799 56.41646 2.058111
Atheist (do not believe in God) 1.553398 22.13592 13.980583 57.86408 4.466019
Buddhist 2.919708 17.27494 15.328467 59.85401 4.622871
Christian (VOL) 5.821918 25.17123 17.808219 46.57534 4.623288
Don’t know/Refused (VOL) 14.800000 21.20000 12.400000 45.60000 6.000000
Hindu 6.614786 24.90272 24.513619 34.63035 9.338521
Jehovah’s Witness (VOL) 28.169014 16.43192 7.042254 46.47887 1.877934
Jewish (Judaism) 2.199413 24.78006 19.648094 47.50733 5.865103
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 3.098107 28.22719 26.678141 34.42341 7.573150
Muslim (Islam) 5.172414 17.24138 15.517241 52.58621 9.482759
Nothing in particular 4.585919 23.73887 16.994875 50.41813 4.262207
Orthodox (Greek, Russian, or some other orthodox church) 6.336088 26.17080 24.517906 35.26171 7.713499
Protestant 3.536207 25.90312 21.402496 43.96012 5.198060
Roman Catholic 3.641109 25.83572 21.809370 42.51274 6.201069
Unitarian (Universalist) (VOL) 1.298701 19.48052 5.844156 72.07792 1.298701


Quesion: Are you very satisfied, somewhat satisfied, somewhat DISsatisfied or very DISsatisfied? (With your personal safety from things like crime and terrorism)

Personal_Safety <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q3d)) %>%  # Ensure q16 and q3a are not NA
  group_by(q16, q3d) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q3d)


Personal_Safety_selected <- select(Personal_Safety, q16, q3d, Percentage)


Personal_Safety_wide <- pivot_wider(
  Personal_Safety_selected,
  names_from = q3d,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Personal_Safety_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Personal_Safety_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Personal Safety Satisfaction" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

table
Personal Safety Satisfaction
Religion Don’t know/Refused (VOL.) Somewhat dissatisfied Somewhat satisfied Very dissatisfied Very satisfied
Agnostic (not sure if there is a God) 1.937046 10.65375 42.25182 4.721550 40.43584
Atheist (do not believe in God) 2.524272 12.81553 36.69903 5.631068 42.33010
Buddhist 4.379562 11.43552 39.41606 5.839416 38.92944
Christian (VOL) 3.938356 14.72603 37.50000 10.445206 33.39041
Don’t know/Refused (VOL) 7.600000 16.00000 35.20000 10.800000 30.40000
Hindu 4.280156 11.28405 34.63035 12.840467 36.96498
Jehovah’s Witness (VOL) 6.103286 16.90141 30.04695 29.107981 17.84038
Jewish (Judaism) 2.346041 14.22287 44.28152 7.038123 32.11144
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 1.549053 12.04819 36.66093 6.368330 43.37349
Muslim (Islam) 2.586207 13.79310 36.20690 10.344828 37.06897
Nothing in particular 3.129215 12.51686 40.94955 9.738333 33.66604
Orthodox (Greek, Russian, or some other orthodox church) 5.234160 11.84573 39.39394 13.498623 30.02755
Protestant 2.473710 14.19386 38.91462 10.690350 33.72746
Roman Catholic 2.696657 14.82540 39.59239 11.445259 31.44029
Unitarian (Universalist) (VOL) 3.896104 10.38961 36.36364 5.844156 43.50649


Now based on this quesions and answer I’m gonna create the measure of Satisfaction within all individuals. Certainly! Here’s the explanation you can use:


Total Satisfaction Metric Explanation:


To quantify overall satisfaction from responses to four questions (q3a, q3b, q3c, q3d) in the survey, a Total Satisfaction Metric is computed. This metric converts qualitative responses into numerical scores using the following mapping:

  • ‘Very satisfied’: Scored as 1
  • ‘Somewhat satisfied’: Scored as 0.75
  • ‘Somewhat dissatisfied’: Scored as 0.25
  • ‘Very dissatisfied’: Scored as 0
  • ‘Don’t know/Refused’: Scored as 0.5 ( My idea was that if somebody can’t classify his answers to binary class of dissatisfied or satisfied, he/she probably has higher satisfaction than someone with dissatisfied answers)

These scores represent the level of satisfaction associated with each response, with higher scores indicating higher levels of satisfaction.

The Total Satisfaction Metric is calculated by summing the scores from the four questions for each respondent. The resulting score provides an aggregate measure of satisfaction, allowing for easy comparison across respondents.

Mathematically, the Total Satisfaction Metric (\(TSM\)) can be represented as:

\[ TSM = \sum_{i=1}^{4} Score_i \]

Where: - \(TSM\) is the Total Satisfaction Metric, - \(Score_i\) is the score assigned to the response for the \(i^{th}\) question.


map_satisfaction_scores <- function(satisfaction, detail) {
  case_when(
    satisfaction == 'Satisfied' & detail == 'Very' ~ 1,
    satisfaction == 'Satisfied' & detail == 'Somewhat' ~ 0.75,
    satisfaction == 'Dissatisfied' & detail == 'Very' ~ 0,
    satisfaction == 'Dissatisfied' & detail == 'Somewhat' ~ 0.25,
    # Assuming 'Don’t know/Refused' is for cases where detail might not be answered
    satisfaction == 'Satisfied' & detail == 'Don’t know/Refused' ~ 0.75, 
    satisfaction == 'Dissatisfied' & detail == 'Don’t know/Refused' ~ 0.25,
    TRUE ~ 0.5  # Default case for any other combinations, including unhandled 'Don’t know/Refused'
  )
}

# Apply this mapping function to your dataset for Q1/Q1a and Q2/Q2a
survey_data_2007 <- survey_data_2007 %>%
  mutate(q1_Score = map_satisfaction_scores(as.character(q1), as.character(q1a)),
         q2_Score = map_satisfaction_scores(as.character(q2), as.character(q2a)))


# Map scores for Q3 questions directly
satisfaction_mapping <- c('Very satisfied' = 1, 'Somewhat satisfied' = 0.75, 'Somewhat dissatisfied' = 0.25, 'Very dissatisfied' = 0, 'Don’t know/Refused' = 0.5)

survey_data_2007 <- survey_data_2007 %>%
  mutate(across(c(q3a, q3b, q3c, q3d), ~ satisfaction_mapping[.], .names = "{.col}_Score"))

# Calculate total satisfaction score
survey_data_2007$Total_Satisfaction <- rowSums(survey_data_2007[, grepl("_Score$", names(survey_data_2007))], na.rm = TRUE)

# Viewing the results
head(survey_data_2007[, c("q1_Score", "q2_Score", "q3a_Score", "q3b_Score", "q3c_Score", "q3d_Score", "Total_Satisfaction")])



average_satisfaction_by_religion <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>%
  summarise(Average_Satisfaction = mean(Total_Satisfaction, na.rm = TRUE))


# Plot the data using ggplot
p <- ggplot(average_satisfaction_by_religion, aes(x = q16, y = Average_Satisfaction, fill = q16)) +
  geom_bar(stat = "identity", width = 0.7) +  # Use identity to indicate that y values are already calculated
  
  labs(title = "Average Satisfaction by Religion",
       x = "Religion",
       y = "Average Satisfaction") +
  
  theme_minimal() +  # Use a minimal theme
  theme(axis.text.x = element_text(angle = 45, hjust = 1),  # Adjust text alignment if needed
        legend.position = "none")  # Remove legend since color coding is redundant

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 800)

# Show the interactive plot in your default browser

interactive_plot



Average Satisfaction by Religious Affiliation:

The average satisfaction levels for various religious affiliations provide valuable insights into the overall contentment reported by individuals within each group. While there are fluctuations across different affiliations, the average satisfaction score serves as a broad indicator of the perceived fulfillment among members of each religious community.

Across the spectrum, the average satisfaction tends to hover around a certain range, typically between 2.4 and 2.7. However, some religious affiliations stand out with notably higher or lower average satisfaction scores.

For instance, Hindus display a relatively high average satisfaction score of 2.70, indicating a generally contented outlook within this religious community. On the other hand, Jehovah’s Witnesses report a lower average satisfaction score of 2.08, suggesting a lower overall satisfaction level among its members.

Among the affiliations with average satisfaction scores that deviate from the norm, Mormons, with an average satisfaction score of 2.80, demonstrate a notably higher level of contentment compared to the general trend. Conversely, individuals identifying as Don’t know/Refused exhibit a slightly lower average satisfaction score of 2.35, indicating a relatively lower reported satisfaction level within this group.

# Create a density plot to visualize the distribution of Total_Satisfaction
p <- ggplot(survey_data_2007, aes(x = Total_Satisfaction)) +
  geom_density(fill = "lightblue", adjust = 4) +
  labs(title = "Density Plot of Total Satisfaction Scores",
       x = "Total Satisfaction Score",
       y = "Density") +
  theme_minimal()

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 500)

# Show the interactive plot in your default browser

interactive_plot


Happiness


Based on the data provided, it seems that individuals who identify with a religious affiliation generally report higher levels of happiness compared to those who do not identify with any religion. Across various religious groups, there appears to be a trend of higher reported happiness levels, with a significant portion of respondents indicating that they are either “Pretty happy” or “Very happy.”

Interestingly, even within religious groups, there is variation in reported happiness levels. For example, Mormons and Unitarian Universalists tend to report particularly high levels of happiness, while Jehovah’s Witnesses and Christians who volunteered their religion report lower levels of happiness compared to some other religious groups.

Overall, while there are differences among various religious affiliations, the data suggests a positive association between religious identification and reported happiness levels.


Happiness <- survey_data_2014 %>%
  group_by(qe1) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(qe1), !is.na(qa1)) %>%  # Ensure qe1 and qa1 are not NA
  group_by(qe1, qa1) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(qe1) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(qe1, qa1)
Happiness_selected <- select(Happiness, qe1, qa1, Percentage)


Happiness_wide <- pivot_wider(
  Happiness_selected,
  names_from = qa1,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Happiness_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Happiness_wide, "html", align = c('l', rep('c', 10))) %>%
  kable_styling("striped", full_width = F) %>%
  add_header_above(c(" " = 1, "How do you describe your Happiness state" = 3, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
How do you describe your Happiness state
Religion (VOL) Don’t know/Refused Not too happy Pretty happy Very happy
Agnostic (not sure if there is a God) 1.289009 10.379919 60.44776 27.88331
Atheist (do not believe in God) 1.548270 9.107468 59.10747 30.23679
Buddhist 2.651515 9.469697 57.95455 29.92424
Christian (VOL) 3.466667 15.600000 48.53333 32.40000
Don’t Know/Refused (VOL) 7.792208 5.194805 51.94805 35.06494
Hindu 1.507538 9.547739 59.29648 29.64824
Jehovah’s Witness (VOL) 4.098361 19.672131 42.21311 34.01639
Jewish (Judaism) 1.534829 11.570248 52.77450 34.12042
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 1.355422 9.186747 51.35542 38.10241
Muslim (Islam) 2.109705 13.080169 50.63291 34.17722
Nothing in particular 1.845907 12.961477 54.35393 30.83868
Orthodox (Greek, Russian, or some other orthodox church) 4.838710 11.290323 54.83871 29.03226
Protestant 2.032572 12.643606 50.50499 34.81884
Roman Catholic 2.543080 13.896609 49.51362 34.04669
Spiritual but not religious (‘believe in God, but…’) (VOL) 6.250000 13.281250 46.87500 33.59375
Unitarian (Universalist) (VOL) 1.212121 5.454546 56.36364 36.96970


p <- ggplot(Happiness, aes(x = qe1, y = qa1, fill = Percentage)) +
  geom_tile() + # Create the tiles for the heatmap
  scale_fill_gradient(low = "white", high = "steelblue") + # Gradient from white (low) to steel blue (high)
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), axis.text.y = element_text(size = 12), title = element_text(size = 20)) +
  labs(title = "Happiness among different Religion",
       x = "Religion",
       y = "Happiness",
       fill = "Percentage")

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 750)

interactive_plot <- interactive_plot %>% layout(autosize = F)
# Show the interactive plot in your default browser

interactive_plot


Average Salary


Analyzing the average income across different religious affiliations provides valuable insights into the economic status and financial well-being of individuals within each group. These figures offer a broad overview of the income levels reported by members of various religious communities, highlighting potential disparities and trends.

# Map income categories to approximate average values
income_mapping <- c(
    'Less than $10,000' = 5000,
    '10 to under $20,000' = 15000,
    '20 to under $30,000' = 25000,
    '30 to under $40,000' = 35000,
    '40 to under $50,000' = 45000,
    '50 to under $75,000' = 62500,
    '75 to under $100,000' = 87500,
    '100 to under $150,000' = 125000,
    '$150,000 or more' = 200000,
    "Don't know/Refused (VOL.)" = NA  # Handle unknown/refused with NA or an appropriate value
)

# Assuming survey_data_2007 is your dataframe
survey_data_2007 <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n()>100) %>% 
  mutate(Average_Income = income_mapping[income])

average_income_by_religion <- survey_data_2007 %>%
  group_by(q16) %>%
  summarise(Average_Income = mean(Average_Income, na.rm = TRUE))  # Excluding NA values

sorted_average_income_by_religion <- average_income_by_religion %>%
  arrange(Average_Income)

# Ensure 'q16' is ordered according to the sorted data
sorted_average_income_by_religion$q16 <- factor(sorted_average_income_by_religion$q16, 
                                                levels = sorted_average_income_by_religion$q16)

# Plot the data using ggplot
p <- ggplot(sorted_average_income_by_religion, aes(x = q16, y = Average_Income, fill = q16)) +
  geom_bar(stat = "identity", width = 0.7) +  # Use identity to indicate that y values are already calculated
  
  labs(title = "Average Income by Religion",
       x = "Religion",
       y = "Average Satisfaction") +
  
  theme_minimal() +  # Use a minimal theme
  theme(axis.text.x = element_text(angle = 45, hjust = 1),  # Adjust text alignment if needed
        legend.position = "none")  # Remove legend since color coding is redundant

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 800)

# Show the interactive plot in your default browser

interactive_plot


The average income among different religious affiliations varies significantly, reflecting diverse economic circumstances and opportunities experienced by individuals within each group.

For instance, Hindus and Jews report relatively higher average incomes compared to other religious affiliations, with Hindus averaging $109,829.55 and Jews averaging $108,230.77. These figures suggest a relatively affluent economic status among members of these religious communities.

On the other hand, Jehovah’s Witnesses report a notably lower average income of $48,531.07, indicating a comparatively lower economic standing within this religious group.

Among the affiliations with average income figures deviating from the norm, atheists and agnostics display relatively higher average incomes, with atheists averaging $85,928.25 and agnostics averaging $79,537.67. Conversely, individuals identifying as Don’t know/Refused report a slightly lower average income of $72,870.37, indicating a relatively lower reported income level within this group.


# Create a density plot to visualize the distribution of Total_Satisfaction
p <- ggplot(survey_data_2007, aes(x = Average_Income)) +
  geom_density(fill = "lightblue", adjust = 4) +
  labs(title = "Density Plot of Income",
       x = "Total Satisfaction Score",
       y = "Density") +
  theme_minimal()

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 500)
## Warning: Removed 6047 rows containing non-finite outside the scale range
## (`stat_density()`).
# Show the interactive plot in your default browser

interactive_plot


Religion and “Culture War” Issues


Abortion


Abortion is a deeply complex and contentious issue that has sparked significant debate and controversy across various societies and cultures. Defined as the termination of a pregnancy by removing an embryo or fetus from the uterus before it can survive outside the womb, abortion raises profound ethical, moral, religious, and legal questions.

In the United States, discussions surrounding abortion have been central to public discourse and policymaking for decades. The fundamental question of whether abortion should be legally permissible and under what circumstances has divided individuals, communities, and religious groups, reflecting differing perspectives on the sanctity of life, bodily autonomy, women’s rights, and the role of government in regulating reproductive healthcare.

Against this backdrop, understanding the views of individuals within different religious affiliations regarding abortion provides valuable insights into the diverse range of beliefs, values, and moral considerations shaping public opinion on this complex issue.


Abortion <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q7)) %>%  # Ensure q16 and q7 are not NA
  group_by(q16, q7) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q7)


Abortion_selected <- select(Abortion, q16, q7, Percentage)


Abortion_wide <- pivot_wider(
  Abortion_selected,
  names_from = q7,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Abortion_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Abortion_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Abortion Should Be…" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Abortion Should Be…
Religion (DO NOT READ) Don’t Know/Refused Illegal in all cases Illegal in most cases Legal in all cases Legal in most cases
Agnostic (not sure if there is a God) 3.389830 1.331719 10.774818 34.987893 49.51574
Atheist (do not believe in God) 4.271845 4.077670 6.990291 44.466019 40.19417
Buddhist 6.082725 2.433090 6.326034 37.712895 47.44526
Christian (VOL) 11.472603 13.184931 25.513699 14.554794 35.27397
Don’t know/Refused (VOL) 21.600000 6.000000 8.000000 26.800000 37.60000
Hindu 7.003891 4.280156 20.233463 21.789883 46.69261
Jehovah’s Witness (VOL) 7.981221 55.399061 21.126761 5.164319 10.32864
Jewish (Judaism) 2.492669 4.252199 6.744868 43.255132 43.25513
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 3.958692 8.950086 60.757315 6.540447 19.79346
Muslim (Islam) 4.310345 12.068965 33.620690 14.655172 35.34483
Nothing in particular 6.123550 7.445374 16.859995 28.324791 41.24629
Orthodox (Greek, Russian, or some other orthodox church) 8.264463 7.988981 18.732782 24.517906 40.49587
Protestant 6.293249 16.765651 31.035798 13.834250 32.07105
Roman Catholic 6.872126 17.211383 27.824034 15.210638 32.88182
Unitarian (Universalist) (VOL) 5.194805 1.298701 3.246753 46.753247 43.50649


Notably, there is considerable diversity in attitudes towards abortion among different religious affiliations:

  • Christian Denominations: Within Christian denominations, opinions vary widely, with some groups, such as Jehovah’s Witnesses and Mormons, expressing stronger opposition to abortion, while others, like Unitarians and Protestants, exhibit more nuanced views, including significant support for abortion rights.

  • Non-Christian Religions: Hindus, Muslims, and Buddhists also display a range of perspectives, with differing proportions advocating for different levels of legality regarding abortion.

  • Non-Affiliated Individuals: In contrast, individuals identifying as having “Nothing in particular” or providing a “Don’t Know/Refused” response tend to demonstrate more nuanced views on abortion, with a greater willingness to support legal access to abortion in certain circumstances.



Homosexuality


The topic of homosexuality elicits diverse perspectives, often influenced by cultural, religious, and personal beliefs. Understanding attitudes towards homosexuality within different religious communities provides valuable insights into the intersections of faith and social acceptance.

Homosexuality <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q5b)) %>%  # Ensure q16 and q7 are not NA
  group_by(q16, q5b) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q5b)


Homosexuality_selected <- select(Homosexuality, q16, q5b, Percentage)


Homosexuality_wide <- pivot_wider(
  Homosexuality_selected,
  names_from = q5b,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Homosexuality_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Homosexuality_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Homosexuality Should Be…" = 3, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Homosexuality Should Be…
Religion DK/REF (VOL) Homosexuality is a way of life that should be accepted by so Homosexuality is a way of life that should be discouraged by Neither/Both equally (VOL)
Agnostic (not sure if there is a God) 3.026634 81.96126 10.048426 4.963680
Atheist (do not believe in God) 2.912621 81.94175 12.427184 2.718447
Buddhist 3.649635 85.15815 8.759124 2.433090
Christian (VOL) 8.390411 45.71918 39.212329 6.678082
Don’t know/Refused (VOL) 13.200000 68.00000 14.000000 4.800000
Hindu 10.894942 48.24903 36.964981 3.891051
Jehovah’s Witness (VOL) 5.164319 10.79812 77.464789 6.572770
Jewish (Judaism) 3.079179 80.20528 13.343108 3.372434
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 3.958692 21.17040 69.879518 4.991394
Muslim (Islam) 3.448276 35.34483 50.862069 10.344828
Nothing in particular 5.071486 67.97950 22.255193 4.693822
Orthodox (Greek, Russian, or some other orthodox church) 9.090909 47.10744 36.639119 7.162534
Protestant 4.958317 37.59603 52.018743 5.426906
Roman Catholic 6.225923 56.38126 31.676401 5.716416
Unitarian (Universalist) (VOL) 1.298701 92.20779 2.597403 3.896104



  • Acceptance vs. Disapproval: Individuals from religious backgrounds, such as Jehovah’s Witnesses, Mormons, and Muslims, tend to express more disapproval towards homosexuality. This aligns with teachings in these faiths that may view homosexuality as inconsistent with religious doctrine or moral principles.

  • Moderate Views: Certain religious groups, such as Protestants and Orthodox Christians, exhibit more moderate perspectives on homosexuality, with a sizable portion expressing neither strong acceptance nor strong disapproval. This suggests a degree of diversity within these religious communities regarding attitudes towards homosexuality.

  • Acceptance: Conversely, individuals identifying as agnostic, atheist, or having “Nothing in particular” as their religious affiliation tend to demonstrate higher levels of acceptance towards homosexuality. This reflects a trend observed among those who may not adhere to specific religious teachings or who prioritize secular values over religious doctrines.

The data underscores the complexity of attitudes towards homosexuality within different religious contexts. While some religious groups exhibit more conservative views, others demonstrate greater acceptance or neutrality. These findings highlight the multifaceted relationship between religion and social attitudes, emphasizing the need for dialogue and understanding across diverse religious perspectives in discussions surrounding LGBTQ+ rights and social inclusion.



Evolution


Question: Evolution is the best explanation for the origins of human life on earth
Debates over the origins of human life have long been a focal point in discussions on science, religion, and philosophy. One of the key areas of contention is the acceptance of evolution as the primary explanation for the origins of human life. Understanding the perspectives of different religious groups on this issue provides valuable insights into the intersection of faith and scientific understanding.


Evolution <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q10c)) %>%  # Ensure q16 and q7 are not NA
  group_by(q16, q10c) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q10c)


Evolution_selected <- select(Evolution, q16, q10c, Percentage)


Evolution_wide <- pivot_wider(
  Evolution_selected,
  names_from = q10c,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Evolution_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Evolution_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Evolution as the Best Explanation for the Origins of Human Life" = 4, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Evolution as the Best Explanation for the Origins of Human Life
Religion Completely agree Completely disagree Don’t know/Refused (VOL.) Mostly agree Mostly disagree
Agnostic (not sure if there is a God) 57.142857 3.753027 2.663438 30.629540 5.811138
Atheist (do not believe in God) 71.067961 4.271845 2.718447 17.087379 4.854369
Buddhist 51.581508 4.136253 4.866180 31.386861 8.029197
Christian (VOL) 16.095890 32.705480 10.102740 22.260274 18.835616
Don’t know/Refused (VOL) 38.800000 11.200000 20.000000 24.800000 5.200000
Hindu 44.357977 4.669261 4.669261 37.743191 8.560311
Jehovah’s Witness (VOL) 1.877934 81.220657 1.877934 3.755869 11.267606
Jewish (Judaism) 51.026393 8.944282 4.985337 28.592375 6.451613
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 5.851979 55.593804 2.581756 14.629948 21.342513
Muslim (Islam) 17.241379 36.206897 5.172414 27.586207 13.793103
Nothing in particular 33.072565 12.408956 7.202590 34.637173 12.678716
Orthodox (Greek, Russian, or some other orthodox church) 22.314050 20.661157 8.815427 33.333333 14.876033
Protestant 11.823680 40.887048 6.750940 23.156977 17.381355
Roman Catholic 21.262582 18.317385 6.983969 33.813844 19.622219
Unitarian (Universalist) (VOL) 62.337662 3.246753 2.597403 26.623377 5.194805


  • High Acceptance: Individuals identifying as atheists, agnostics, and Unitarians demonstrate the highest levels of agreement with evolution as the best explanation for human life’s origins. This aligns with the scientific consensus and reflects a tendency among those with more secular or progressive religious views to embrace evolutionary theory.

  • Moderate Acceptance: Certain religious groups, such as Buddhists and Jews, exhibit moderate levels of agreement with evolution. While not as high as atheists or agnostics, these groups still show a substantial proportion endorsing evolutionary theory, suggesting a degree of compatibility between their religious beliefs and scientific understanding.

  • Low Acceptance: Conversely, individuals from more conservative religious backgrounds, such as Jehovah’s Witnesses, Mormons, and Muslims, tend to express lower levels of agreement with evolution. This likely reflects theological teachings or interpretations that may conflict with evolutionary principles.

Conclusion: The data highlights the diversity of perspectives among different religious groups regarding the acceptance of evolution as the best explanation for human life’s origins. While some religious traditions demonstrate high levels of acceptance, others exhibit more skepticism or outright rejection of evolutionary theory. These findings underscore the complex relationship between religion and science, emphasizing the importance of fostering dialogue and understanding across diverse religious perspectives in discussions concerning the origins of human life.



Churches and Politics


Question: In your opinion, should churches and other houses of worship keep out of political matters - or should they express their views on day-to-day social and political questions?


The role of churches in expressing views on political matters is a topic of considerable debate and contention. While some argue that churches should actively engage in political discourse as part of their societal role, others advocate for a separation of church and state, suggesting that religious institutions should refrain from direct involvement in political affairs.


Church_politics <- survey_data_2007 %>%
  group_by(q16) %>% 
  filter(n() > 100) %>% # Keep only religions with more than 100 respondents
  ungroup() %>% 
  filter(!is.na(q16), !is.na(q9)) %>%  # Ensure q16 and q7 are not NA
  group_by(q16, q9) %>%
  summarise(Count = n(), .groups = 'drop') %>%  # Count occurrences and drop grouping
  ungroup() %>% 
  group_by(q16) %>%
  mutate(Total = sum(Count), 
         Percentage = (Count / Total) * 100) %>%
  ungroup() %>% 
  arrange(q16, q9)


Church_politics_selected <- select(Church_politics, q16, q9, Percentage)


Church_politics_wide <- pivot_wider(
  Church_politics_selected,
  names_from = q9,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)

colnames(Church_politics_wide)[1] <- "Religion"

# Create the table with kable and add styling with kableExtra
table <- kable(Church_politics_wide, "html") %>%
  kable_styling("striped", full_width = T) %>%
  add_header_above(c(" " = 1, "Should Churches Express Views on Politics?" = 2, " " = 1)) %>%
  row_spec(0, bold = T, color = "white", background = "#636363") %>%
  scroll_box( height = "100%") %>% 
  column_spec(1, bold = T) 

# If you want to see the table in RStudio's Viewer
table
Should Churches Express Views on Politics?
Religion Don’t know/Refused Should express views Should keep out
Agnostic (not sure if there is a God) 3.510896 27.845036 68.64407
Atheist (do not believe in God) 4.077670 22.524272 73.39806
Buddhist 7.785888 34.063260 58.15085
Christian (VOL) 5.821918 48.801370 45.37671
Don’t know/Refused (VOL) 10.000000 29.200000 60.80000
Hindu 6.225681 22.178988 71.59533
Jehovah’s Witness (VOL) 6.572770 9.859155 83.56808
Jewish (Judaism) 3.958944 31.818182 64.22287
Mormon (Church of Jesus Christ of Latter-day Saints/LDS) 4.991394 44.922547 50.08606
Muslim (Islam) 0.862069 52.586207 46.55172
Nothing in particular 4.882654 34.367413 60.74993
Orthodox (Greek, Russian, or some other orthodox church) 4.132231 39.669421 56.19835
Protestant 4.211845 56.568408 39.21975
Roman Catholic 4.200323 46.737915 49.06176
Unitarian (Universalist) (VOL) 7.142857 35.714286 57.14286



  • Support for Expression: Individuals identifying as Protestants, Mormons, and Christians generally favor churches expressing views on political matters. This inclination may stem from a belief in the moral authority of religious institutions and their role in shaping societal values and policies.

  • Preference for Neutrality: Conversely, atheists, agnostics, and Unitarians tend to advocate for churches keeping out of political issues. This reflects a desire to maintain a clear separation between religious and political domains, preserving individual autonomy and diversity of belief.

  • Moderate Views: Some religious groups, such as Buddhists, Jews, and Hindus, demonstrate more mixed perspectives. While they may acknowledge the potential for churches to engage in political discourse, they also recognize the importance of maintaining impartiality and avoiding undue influence on political processes.


Conclusion

The survey data from various religious and non-religious groups reveal profound insights into how religion influences social perceptions, behaviors, and personal satisfaction within society. It suggests that religion can be both a source of conflict and a provider of community, shaping attitudes toward modern societal norms and personal well-being in diverse ways.

Influence on Societal Views: Individuals from religious backgrounds often view their faith as a stabilizing force, contributing positively to their lives and communities. This is evident in the higher satisfaction rates regarding family and personal life among those with strong religious affiliations like Hindus and Mormons. In contrast, non-religious individuals, including atheists and agnostics, tend to view religion more critically, often perceiving it as a source of social tension or conflict. This group is more likely to believe that religion complicates social issues rather than resolves them, highlighting a stark difference in how the role of religion in society is perceived.

Impact on Ethical and Social Issues: The data shows that religious beliefs significantly influence attitudes towards contentious social and ethical issues such as abortion and homosexuality. More conservative views are prevalent among traditionally religious groups like Jehovah’s Witnesses and Mormons, while more liberal views tend to be held by those who are non-religious or part of more progressive religious groups like Unitarians. This division underscores how religious doctrines can shape fundamental social attitudes and behaviors.

Adaptation to Modernity: There is a perceived conflict between devout religious practice and living in a modern society, particularly among groups with strict doctrinal adherence. However, many believers find ways to reconcile their faith with modern values, indicating that religion evolves with societal changes. Non-religious individuals also face their own challenges, particularly in societies where religious norms predominate, suggesting a universal theme of navigating personal beliefs in diverse social landscapes.

General Well-being and Religion: The relationship between religion and personal satisfaction is complex. While religious affiliation often correlates with higher levels of family and personal life satisfaction—possibly due to stronger community bonds and support systems—the less religious report varying degrees of satisfaction, influenced by their personal and social environments.


Chapter 4 : Modelings


Modeling Religious Affiliation Dynamics: A Transition Probability Approach


For Chapter 4 of your project, you are conducting an exploration of religious dynamics, focusing specifically on how individuals transition between religions from childhood to adulthood. Your analysis aims to model the changing composition of religious affiliations in a society over time, using a matrix of transition probabilities. Here’s a structured and clear explanation of your approach and objectives:

Purpose of the Analysis

The primary goal of this analysis is to understand the dynamics of religious affiliation in society by studying how individuals may change their religious affiliations from childhood to adulthood. You seek to:

  1. Quantify the Transition Probabilities: Calculate the probability that a person born or identified with one religion (childhood religion) will transition to another religion (adulthood religion). This involves analyzing survey data to determine the proportion of individuals who switch from each religion to another, compared to the total number of individuals who started in each religion.

  2. Simulate Religious Composition Over Time: Use the calculated transition probabilities to simulate how the distribution of religious affiliations changes over time within a fixed population. This simulation will help visualize potential trends and shifts in religious composition under the assumption that no other demographic factors (like birth, death, or immigration) affect the population.

  3. Identify Steady States: Determine if the simulation reaches a steady state where the proportions of each religion in the population remain constant over successive time periods, suggesting a balance in how individuals transition between religions.

Methodology

Calculation of Transition Probabilities

For each religion X (childhood religion), calculate the probability of transitioning to each religion Y (adulthood religion) as follows:

\[ P(Y|X) = \frac{\text{Number of people who changed their religion from } X \text{ to } Y}{\text{Total number of children with religion } X} \]

This results in a transition matrix where each element (i, j) represents the probability of transitioning from religion i to religion j.

Simulation of Religious Composition
  • Initial Setup: Start with the initial distribution of religious affiliations based on the survey data.
  • Application of Transition Matrix: At each simulation step, apply the transition matrix to the current distribution of religions to obtain the distribution for the next time period.
  • Repeat Until Steady State: Continue applying the transition matrix over multiple time periods to observe how the religious composition evolves until it stabilizes or reaches a steady state.


# the columns are named 'qj1' for childhood religion and 'qe1' for current religion
transition_counts <- survey_data_2014 %>%
  filter(!is.na(qj1) & !is.na(qe1)) %>% 
  group_by(qj1) %>% 
  filter(n()>100) %>% 
  ungroup() %>% 
  group_by(qe1) %>% 
  filter(n()>150) %>% 
  ungroup() %>%
  group_by(qj1,qe1) %>%
  filter(n()>10) %>%
  summarise(count = n()) %>%
  ungroup()

# Summarize total counts for each childhood religion
total_per_child_religion <- transition_counts %>%
  group_by(qj1) %>%
  summarise(Total_Count = sum(count))

# Calculate percentages
transition_percentages <- transition_counts %>%
  left_join(total_per_child_religion, by = "qj1") %>%
  mutate(Percentage = (count / Total_Count) * 100) %>%
  select(qj1, qe1, count, Percentage)


# Create nodes and links for the Sankey diagram
node_names <- unique(c(as.character(transition_counts$qj1), as.character(transition_counts$qk1)))
nodes <- data.frame(name = node_names)
links <- transition_counts %>%
  mutate(source = match(qj1, node_names) - 1,  # Indexing starts at 0 for JavaScript
         target = match(qe1, node_names) - 1,
         value = count)


# First we need to create an igraph object from the transition data
graph_data <- transition_percentages %>%
  select(source = qj1, target = qe1, weight = Percentage)



# Create the graph object using igraph
graph <- graph_from_data_frame(transition_percentages, directed = TRUE)

# Create groups based on connected components if there is no explicit community detection
com <- components(graph)
grp <- com$membership

# Add group information to the nodes/vertices
V(graph)$group <- grp



mycolors <- RColorBrewer::brewer.pal(min(max(grp), 8), "Set1")
if (max(grp) > 8) {
  mycolors <- grDevices::colors()[seq(from = 1, to = max(grp))]
}
names(mycolors) <- unique(grp)

# Make the arc diagram with ggraph
p <- ggraph(graph, layout = 'linear') + 
  geom_edge_arc(edge_width = 0.3, edge_colour="black", edge_alpha=0.2, fold=TRUE) +
  geom_node_point(aes(size = degree(graph, v = V(graph)), color = factor(group)), alpha = 0.5) +
  scale_size_continuous(range=c(0.5,8)) +
  scale_color_manual(values=mycolors) +
  geom_node_text(aes(label=name), angle=65, hjust=1, nudge_y = -1.1, size=2.3) +
  labs(title = 'transition of religions')+
  theme_void() +
  theme(
    title = element_text(size = 20),
    legend.position="none",
    plot.margin=unit(c(0,0,0.4,0), "null"),
    panel.spacing=unit(c(0,0,3.4,0), "null")
  ) +
  expand_limits(x = c(-1.2, 1.2), y = c(-5.6, 1.2)) 

# Use ggsave() to save the plot with specified dimensions
ggsave("arc_diagram.png", plot = p, width = 12, height = 8, units = "in", dpi = 300)




This arc diagram visually represents the transitions individuals make from their childhood religion to their current religion. Each node (dot) on the horizontal axis represents a different religious affiliation, and the arcs (curved lines) indicate the movement of people between these affiliations over time. The size of a node reflects the number of individuals who either remain in or leave a particular religion.


transition_percentages_2014_selected <- select(transition_percentages, qj1, qe1, Percentage)


transition_percentages_2014_wide <- pivot_wider(
  transition_percentages_2014_selected,
  names_from = qj1,  # This column's unique values will become the names of the new columns
  values_from = Percentage,  # The cell values will come from the 'Percentage' column
  values_fill = list(Percentage = 0)  # Fill missing combinations with 0%
)
transition_percentages_2014_wide
# Heatmap for both years
p <- ggplot(transition_percentages_2014_selected, aes(x = qe1, y = qj1, fill = Percentage)) +
  geom_tile() + # Create the tiles for the heatmap
  scale_fill_gradient(low = "white", high = "steelblue") + # Gradient from white (low) to steel blue (high)
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), title = element_text(size = 15)) +
  labs(title = "Transition Probability of changing religion",
       x = "Adulthood Religion",
       y = "Childhood Religion",
       fill = "Percentage")

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 750)

# Show the interactive plot in your default browser

interactive_plot


The heatmap depicts changes in religious affiliation from childhood to adulthood across various groups. Observing the concentration of darker shades along the diagonal would suggest that many individuals remain within their childhood religion. However, deviations from the diagonal where darker shades appear indicate notable transitions from one religion to another (notable for Protestant and Nothing in particular).


To simulate the evolution of the population’s religious affiliations, we start with an initial population vector \(\mathbf{P}(0)\), where each element \(P_i(0)\) represents the number of individuals affiliated with religion \(i\) at the beginning of our simulation (time \(t = 0\)).

At each subsequent time point \(t\), we update the population vector using the following formula:

\[ \mathbf{P}(t) = \mathbf{P}(t-1) \times \mathbf{T} \]

where: - \(\mathbf{P}(t)\) is the population vector at time \(t\), with \(P_i(t)\) being the number of individuals affiliated with religion \(i\). - \(\mathbf{P}(t-1)\) is the population vector from the previous time point \(t-1\). - \(\mathbf{T}\) is the transition matrix, with each element \(T_{ij}\) representing the probability of an individual transitioning from religion \(i\) to religion \(j\).

The multiplication of \(\mathbf{P}(t-1)\) by \(\mathbf{T}\) applies the transition probabilities to the population vector, producing a new distribution of religious affiliations at time \(t\). This process models how individuals may change their religious affiliations over time, allowing us to forecast the potential shifts in the religious composition of the population.

By repeating this calculation for each time step, we construct a time series of population vectors \(\{ \mathbf{P}(1), \mathbf{P}(2), \ldots, \mathbf{P}(t) \}\), which depict the dynamics of religious affiliation within the population across the simulated time periods.


# Convert percentage to probability
transition_matrix <- transition_percentages_2014_wide %>%
  select(-qe1) %>% # Remove the first column which contains labels
  mutate_all(~ .x / 100) # Convert percentages to probabilities


# Convert percentages to probabilities (divide by 100)
transition_percentages_2014_selected$Percentage <- transition_percentages_2014_selected$Percentage / 100

# Creating a wide matrix with all religions both in rows and columns
transition_matrix <- transition_percentages_2014_selected %>%
  spread(key = qj1, value = Percentage, fill = 0)  # Use the correct key and value fields

# Ensure all unique religions are included as rows and columns
all_religions <- union(unique(transition_percentages_2014_selected$qe1), unique(transition_percentages_2014_selected$qj1))

# Create an empty full transition matrix with zeros
full_matrix <- matrix(0, nrow = length(all_religions), ncol = length(all_religions),
                      dimnames = list(all_religions, all_religions))

# Fill the full matrix with the available probabilities
for (i in 1:nrow(transition_percentages_2014_selected)) {
  from_religion <- transition_percentages_2014_selected$qe1[i]
  to_religion <- transition_percentages_2014_selected$qj1[i]
  probability <- transition_percentages_2014_selected$Percentage[i]
  full_matrix[from_religion, to_religion] <- probability
}

# Convert to a data frame for visualization/checking
transition_df <- as.data.frame(full_matrix)


simulate_religion_dynamics <- function(pop, P, max_time) {
  pop_matrix <- matrix(0, nrow = max_time, ncol = length(pop))
  pop_matrix[1,] <- pop
  for (t in 2:max_time) {
    pop_matrix[t,] <- pop_matrix[t-1,] %*% P
  }
  return(pop_matrix)
}

# Initial Population based on the data
initial_population <- c(1474 , 1098 , 5000, 15000, 264, 750, 7200, 200, 199, 244, 847, 664, 237, 186)

# Run the simulation
result <- simulate_religion_dynamics(initial_population, t(full_matrix), max_time = 40)

# Assuming 'result' is your matrix from the simulation
result_df <- as.data.frame(result)
time <- 1:nrow(result_df)
result_df <- cbind(time, result_df)

# Melt the data frame for ggplot
result_long <- result_df %>%
  pivot_longer(cols = -time, names_to = "Religion", values_to = "Population")

# # Name the religions appropriately if not automatically named
religions <- names(transition_df)
result_long$Religion <- rep(religions, times = 40)


p <- ggplot(result_long, aes(x = time, y = Population, color = Religion )) +
  geom_line() +
  theme_minimal() +
  labs(title = "Religion Population Dynamics",
       x = "Time",
       y = "Population") +
  
  theme(legend.title = element_blank())


# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 600)

# Show the interactive plot in your default browser

interactive_plot


Conclusion

The graph shows us a snapshot of religious shifts over time. We observe that the number of individuals identifying as Protestant and those stating “Nothing in particular” are on the rise, while the Roman Catholic group is seeing a decrease. Other religions appear to be fairly steady in their numbers. These trends are mostly consistent with the actual changes in religious affiliation observed between 2007 and 2014, with the growth of the Protestant group as an exception.

It’s important to note that this is a simplified model that doesn’t account for factors like immigration, birth, and mortality rates, which all play a significant role in shaping the religious composition of a population. Nonetheless, this model serves as a promising starting point for more detailed future studies that could incorporate these additional elements.


Analyzing the Predictors of Religious Change from Childhood to Adulthood Using Random Forest and GLM


Random Forest Classifier


Understanding how and why individuals change their religious beliefs over time is crucial for both sociological research and practical applications within community planning and policy making. The complexity of religious belief systems and their influence on personal and social life demand a sophisticated analytical approach to capture the nuanced changes individuals may experience.


# Calculate the percentage of missing values for each column
missing_percentage <- sapply(survey_data_2014, function(x) sum(is.na(x)) / length(x)) * 100

# Set threshold for removal
threshold <- 0

# Find columns with missing value percentage greater than the threshold
columns_to_remove <- names(missing_percentage[missing_percentage > threshold])

# Remove the columns from the dataset
data_clean_2014 <- survey_data_2014[, !(names(survey_data_2014) %in% columns_to_remove)]

data_clean_2014 <- data_clean_2014 %>%
  mutate(Religion_Change = if_else(qj1 == qe1, "Same", "Changed")) %>% 
  filter(respondent_birthregion != "Don't know/refused") %>%  # Remove "Don't know/refused"
  mutate(Immigration_Status = if_else(respondent_birthregion == "U.S.", "Non-Immigrant", "Immigrant"))

# # Remove feature
data_clean_2014 <- select(data_clean_2014,-qj1, -qe1)

# # Ensure the target variable is a factor
data_clean_2014$Religion_Change <- factor(data_clean_2014$Religion_Change)

data_clean_2014 <- data_clean_2014 %>% 
  select( -RELTRAD, -CHRELTRAD, -CHFAMILY, -CHDENOM, -CHPROTFAM, -FAMILY, -PROTFAM, -DENOM, -WEIGHT, -resp,-...1,)


set.seed(123)  # for reproducibility
indices <- sample(1:nrow(data_clean_2014), size = 0.7 * nrow(data_clean_2014))
train_data <- data_clean_2014[indices, ]
test_data <- data_clean_2014[-indices, ]



rf_classifier <- randomForest(Religion_Change ~ ., data = train_data, ntree = 200)

# Making predictions
predictions <- predict(rf_classifier, test_data)

# Evaluate model performance
conf_matrix <- table(Predicted = predictions, Actual = test_data$Religion_Change)
accuracy <- sum(diag(conf_matrix)) / sum(conf_matrix)
print(paste("Accuracy: ", accuracy))
## [1] "Accuracy:  0.750549345562243"
conf_matrix
##          Actual
## Predicted Changed Same
##   Changed    1683  597
##   Same       2014 6173
#rain the Random Forest classifier using the training data. Assume that all other columns except your target variable (Religion_Change) are predictors.


The accuracy of your Random Forest model is approximately 75.05%, indicating that about three-quarters of the predictions made by the model are correct. The confusion matrix provides a more detailed breakdown of the model’s performance:

  • True Positives (TP): 1683 instances where the model correctly predicted ‘Changed’.
  • True Negatives (TN): 6173 instances where the model correctly predicted ‘Same’.
  • False Positives (FP): 597 instances where the model incorrectly predicted ‘Changed’ when the actual class was ‘Same’.
  • False Negatives (FN): 2014 instances where the model incorrectly predicted ‘Same’ when the actual class was ‘Changed’.


# Assuming 'rf' is your trained random forest model
importance_data <- importance(rf_classifier)
importance_df <- as.data.frame(importance_data)
importance_df$Feature <- rownames(importance_df)

# Using ggplot2 to create the importance plot with gradient color
p <- ggplot(importance_df, aes(x = reorder(Feature, MeanDecreaseGini), y = MeanDecreaseGini, fill = MeanDecreaseGini)) +
  geom_col() +  # Removing the specific fill color from geom_col
  scale_fill_gradient(low = "lightblue", high = "dodgerblue") +  # Define gradient from light blue to dodger blue
  coord_flip() +  # Flip coordinates for horizontal layout
  labs(title = "Feature Importance", x = "Features", y = "Increase in Node Purity") +
  theme_minimal()

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 1000)

# Show the interactive plot in your default browser

interactive_plot


In my analysis, numerous features significantly impact the classification results. However, for the next phase of the study, I aim to focus on features that offer clearer interpretability. Specifically, we plan to hone in on variables like income, education, age, political affiliation, marital status, self-reported happiness, and geographic location. These factors are not only straightforward to understand but also tend to have direct and tangible effects on individuals’ life decisions and perspectives.

By narrowing our analysis to these interpretable factors, I hope to see how the results differ when we limit the model to variables that are more conceptually accessible and traditionally relevant in sociological research. Additionally, this approach will allow us to identify which of these easily understandable factors are most influential in predicting changes in religious affiliation, thereby enhancing the practical applicability and relevance of our findings.


data_clean_2014 <- data_clean_2014 %>% 
  select(Religion_Change , agerec, income, educ, state, cregion, marital, qa1, qa2a, qa2b, qf2, attend)

# Renaming columns
data_clean_2014 <- data_clean_2014 %>%
  rename(
    
    religious_importance = qf2,
    happiness = qa1,
    family_life_satisfaction = qa2a,
    health_life_satisfaction = qa2b,

  )

set.seed(123)  # for reproducibility
indices <- sample(1:nrow(data_clean_2014), size = 0.7 * nrow(data_clean_2014))
train_data <- data_clean_2014[indices, ]
test_data <- data_clean_2014[-indices, ]

rf_classifier <- randomForest(Religion_Change ~ ., data = train_data, ntree = 200)

# Making predictions
predictions <- predict(rf_classifier, test_data)

# Evaluate model performance
conf_matrix <- table(Predicted = predictions, Actual = test_data$Religion_Change)
accuracy <- sum(diag(conf_matrix)) / sum(conf_matrix)
print(paste("Accuracy: ", accuracy))
## [1] "Accuracy:  0.717206458393045"
conf_matrix
##          Actual
## Predicted Changed Same
##   Changed    1581  844
##   Same       2116 5926


Even after reducing the dimensionality of our feature set to focus on 11 easily interpretable factors, the results remain quite comparable to the previous broader model. The accuracy of the current model stands at approximately 71.72%, only slightly lower than the earlier model’s accuracy of 75.05%. This suggests that these selected interpretable factors—such as income, education, age, and others—still capture a significant portion of the variability needed to predict changes in religious affiliation effectively. This reduction in complexity, while maintaining a similar level of predictive power, underscores the relevance and robustness of these key factors in our analysis.


# Assuming 'rf' is your trained random forest model
importance_data <- importance(rf_classifier)
importance_df <- as.data.frame(importance_data)
importance_df$Feature <- rownames(importance_df)

# Using ggplot2 to create the importance plot with gradient color
p <- ggplot(importance_df, aes(x = reorder(Feature, MeanDecreaseGini), y = MeanDecreaseGini, fill = MeanDecreaseGini)) +
  geom_col() +  # Removing the specific fill color from geom_col
  scale_fill_gradient(low = "lightblue", high = "dodgerblue") +  # Define gradient from light blue to dodger blue
  coord_flip() +  # Flip coordinates for horizontal layout
  labs(title = "Feature Importance", x = "Features", y = "Increase in Node Purity") +
  theme_minimal()

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 600)

# Show the interactive plot in your default browser

interactive_plot


  1. religious_importance (1565.3918): This is the most significant factor, indicating the personal significance of religion to an individual. A higher or lower value here directly impacts one’s likelihood to maintain or change their religious affiliation, reflecting the core of how individuals perceive and prioritize their faith.

  2. state (1495.3427): The state where an individual resides is a crucial factor, likely due to the diverse religious landscapes across different states. This can influence exposure to various religious practices and communities, affecting personal religious changes.

  3. agerec (1269.5415): Age often correlates with changes in life perspective and priorities. As people age, their life experiences can lead to shifts in religious beliefs and practices, making this a key predictor of religious change.

  4. income (1213.9837): Financial status influences many aspects of a person’s life, including the ability to participate in certain religious activities, exposure to diverse cultures, and general life satisfaction, all of which can affect religious affiliation.

  5. educ (979.5771): Educational attainment exposes individuals to various worldviews and critical thinking skills, which can lead to questioning and potentially changing religious beliefs.

  6. attend (876.4653): The frequency with which individuals attend religious services is both an indicator of current religious engagement and a predictor of future religious adherence or change.

  7. health_life_satisfaction (633.0054): How satisfied individuals are with their health can impact their spiritual beliefs, particularly as people often turn towards or away from spirituality in times of health crises.

  8. marital (646.6567): Changes in marital status can profoundly affect personal life, including religious practices and beliefs, as marriage can introduce new dynamics and influences regarding religion.

  9. happiness (552.6725): Overall happiness might influence how individuals feel about their current religious standings. Satisfied individuals might see no reason for change, whereas those less happy might seek new spiritual paths.

  10. cregion (469.2322): Similar to state, the broader cultural and regional setting can influence religious practices and changes, reflecting the social and cultural diversity impacting religious identity.

  11. family_life_satisfaction (435.1318): Satisfaction with family life can significantly influence religious stability or change. Family dynamics often play a crucial role in religious upbringing and continued practice.

These factors, listed by their importance, provide a comprehensive view of the determinants most predictive of changes in religious affiliation. Understanding these can help in developing targeted interventions, policies, and further research into the dynamics of religious identity.


GLM Model


In exploring factors that influence changes in religious beliefs, it’s crucial to employ a statistical method that not only effectively handles binary outcomes but also provides interpretable results. This is where Generalized Linear Models (GLM) come into play, offering a robust framework for our analysis.

Why GLM? GLMs are particularly adept at modeling binary outcomes—such as whether an individual has changed their religious affiliation (Yes/No). This capability stems from the model’s use of a logistic function, which naturally maps any input through predictors to a probability between 0 and 1, perfectly suiting binary classification tasks.

Additionally, GLMs bring a high level of interpretability to the table. Each predictor’s effect is quantified with a coefficient that directly corresponds to the change in the log odds of the outcome per unit change in the predictor, holding all other predictors constant. This characteristic makes it easier to understand which factors are most influential in determining religious changes and allows these effects to be directly communicated in terms of odds ratios—a format that is intuitively understandable for both technical and non-technical audiences.


# First make sure to use as.factor for catagorical predictors
data_clean_2014$religious_importance <- as.factor(data_clean_2014$religious_importance)
data_clean_2014$educ <- as.factor(data_clean_2014$educ)
data_clean_2014$income <- as.factor(data_clean_2014$income)  
data_clean_2014$marital <- as.factor(data_clean_2014$marital)
data_clean_2014$attend <- as.factor(data_clean_2014$attend)
data_clean_2014$agerec <- as.factor(data_clean_2014$agerec)



glm_model <- glm(Religion_Change ~ income + educ + agerec + marital + attend + religious_importance   , family = binomial(link = "logit"), data = data_clean_2014)

# Display the summary of the model
summary(glm_model)
## 
## Call:
## glm(formula = Religion_Change ~ income + educ + agerec + marital + 
##     attend + religious_importance, family = binomial(link = "logit"), 
##     data = data_clean_2014)
## 
## Coefficients:
##                                                                                                                          Estimate
## (Intercept)                                                                                                              -1.07512
## income$150,000 or more                                                                                                    0.02589
## income10 to under $20,000                                                                                                -0.14114
## income100 to under $150,000                                                                                               0.03947
## income20 to under $30,000                                                                                                -0.14344
## income30 to under $40,000                                                                                                -0.05627
## income40 to under $50,000                                                                                                -0.01191
## income50 to under $75,000                                                                                                -0.02349
## income75 to under $100,000                                                                                               -0.02663
## incomeLess than $10,000                                                                                                  -0.23246
## educFour year college or university degree/Bachelor's degree (e.g., BS, BA, AB)                                           0.30998
## educHigh school graduate (Grade 12 with diploma or GED certificate)                                                       0.41271
## educHigh school incomplete (Grades 9-11 or Grade 12 with NO diploma)                                                      0.34843
## educLess than high school (Grades 1-8 or no formal schooling)                                                             0.50747
## educPostgraduate or professional degree, including master's, doctorate, medical or law degree (e.g., MA, MS, PhD, MD...)  0.30821
## educSome college, no degree (includes some community college)                                                             0.21628
## educSome postgraduate or professional schooling, no postgraduate degree (e.g. some graduate school)                       0.36987
## educTwo year associate degree from a college or university                                                                0.27343
## agerec35-39                                                                                                              -0.07722
## agerec40-44                                                                                                               0.03336
## agerec45-49                                                                                                               0.16720
## agerec50-54                                                                                                               0.17924
## agerec55-59                                                                                                               0.22840
## agerec60-64                                                                                                               0.30649
## agerec65-69                                                                                                               0.45991
## agerec70-74                                                                                                               0.38036
## agerec75-79                                                                                                               0.54391
## agerec80-84                                                                                                               0.57401
## agerec85-89                                                                                                               0.88778
## agerecAge 24 or younger                                                                                                  -0.03947
## agerecAge 25-29                                                                                                          -0.04880
## agerecAge 90 or older                                                                                                     0.96888
## agerecDon't know/refused                                                                                                  0.27943
## maritalDivorced                                                                                                           0.26950
## maritalLiving with a partner                                                                                              0.17214
## maritalMarried                                                                                                            0.36426
## maritalNever been married                                                                                                 0.45845
## maritalSeparated                                                                                                          0.30206
## maritalWidowed                                                                                                            0.44564
## attendA few times a year                                                                                                  0.22583
## attendMore than once a week                                                                                               0.22907
## attendNever                                                                                                              -0.60065
## attendOnce a week                                                                                                         0.38835
## attendOnce or twice a month                                                                                               0.40638
## attendSeldom                                                                                                             -0.24097
## religious_importanceNot at all important                                                                                 -0.73885
## religious_importanceNot too important                                                                                     0.18073
## religious_importanceSomewhat important                                                                                    0.91826
## religious_importanceVery important                                                                                        1.16394
##                                                                                                                          Std. Error
## (Intercept)                                                                                                                 0.29580
## income$150,000 or more                                                                                                      0.05738
## income10 to under $20,000                                                                                                   0.05555
## income100 to under $150,000                                                                                                 0.05402
## income20 to under $30,000                                                                                                   0.05443
## income30 to under $40,000                                                                                                   0.05560
## income40 to under $50,000                                                                                                   0.05719
## income50 to under $75,000                                                                                                   0.05018
## income75 to under $100,000                                                                                                  0.05251
## incomeLess than $10,000                                                                                                     0.06093
## educFour year college or university degree/Bachelor's degree (e.g., BS, BA, AB)                                             0.19063
## educHigh school graduate (Grade 12 with diploma or GED certificate)                                                         0.19068
## educHigh school incomplete (Grades 9-11 or Grade 12 with NO diploma)                                                        0.19854
## educLess than high school (Grades 1-8 or no formal schooling)                                                               0.20471
## educPostgraduate or professional degree, including master's, doctorate, medical or law degree (e.g., MA, MS, PhD, MD...)    0.19147
## educSome college, no degree (includes some community college)                                                               0.19114
## educSome postgraduate or professional schooling, no postgraduate degree (e.g. some graduate school)                         0.20588
## educTwo year associate degree from a college or university                                                                  0.19274
## agerec35-39                                                                                                                 0.06767
## agerec40-44                                                                                                                 0.06658
## agerec45-49                                                                                                                 0.06546
## agerec50-54                                                                                                                 0.06205
## agerec55-59                                                                                                                 0.06142
## agerec60-64                                                                                                                 0.06199
## agerec65-69                                                                                                                 0.06418
## agerec70-74                                                                                                                 0.06882
## agerec75-79                                                                                                                 0.08112
## agerec80-84                                                                                                                 0.09016
## agerec85-89                                                                                                                 0.12265
## agerecAge 24 or younger                                                                                                     0.06495
## agerecAge 25-29                                                                                                             0.06658
## agerecAge 90 or older                                                                                                       0.17978
## agerecDon't know/refused                                                                                                    0.10781
## maritalDivorced                                                                                                             0.17970
## maritalLiving with a partner                                                                                                0.18310
## maritalMarried                                                                                                              0.17697
## maritalNever been married                                                                                                   0.17926
## maritalSeparated                                                                                                            0.19354
## maritalWidowed                                                                                                              0.18237
## attendA few times a year                                                                                                    0.16225
## attendMore than once a week                                                                                                 0.16324
## attendNever                                                                                                                 0.16426
## attendOnce a week                                                                                                           0.16205
## attendOnce or twice a month                                                                                                 0.16341
## attendSeldom                                                                                                                0.16230
## religious_importanceNot at all important                                                                                    0.13593
## religious_importanceNot too important                                                                                       0.13333
## religious_importanceSomewhat important                                                                                      0.13091
## religious_importanceVery important                                                                                          0.12995
##                                                                                                                          z value
## (Intercept)                                                                                                               -3.635
## income$150,000 or more                                                                                                     0.451
## income10 to under $20,000                                                                                                 -2.541
## income100 to under $150,000                                                                                                0.731
## income20 to under $30,000                                                                                                 -2.635
## income30 to under $40,000                                                                                                 -1.012
## income40 to under $50,000                                                                                                 -0.208
## income50 to under $75,000                                                                                                 -0.468
## income75 to under $100,000                                                                                                -0.507
## incomeLess than $10,000                                                                                                   -3.815
## educFour year college or university degree/Bachelor's degree (e.g., BS, BA, AB)                                            1.626
## educHigh school graduate (Grade 12 with diploma or GED certificate)                                                        2.164
## educHigh school incomplete (Grades 9-11 or Grade 12 with NO diploma)                                                       1.755
## educLess than high school (Grades 1-8 or no formal schooling)                                                              2.479
## educPostgraduate or professional degree, including master's, doctorate, medical or law degree (e.g., MA, MS, PhD, MD...)   1.610
## educSome college, no degree (includes some community college)                                                              1.132
## educSome postgraduate or professional schooling, no postgraduate degree (e.g. some graduate school)                        1.797
## educTwo year associate degree from a college or university                                                                 1.419
## agerec35-39                                                                                                               -1.141
## agerec40-44                                                                                                                0.501
## agerec45-49                                                                                                                2.554
## agerec50-54                                                                                                                2.889
## agerec55-59                                                                                                                3.719
## agerec60-64                                                                                                                4.944
## agerec65-69                                                                                                                7.166
## agerec70-74                                                                                                                5.527
## agerec75-79                                                                                                                6.705
## agerec80-84                                                                                                                6.367
## agerec85-89                                                                                                                7.238
## agerecAge 24 or younger                                                                                                   -0.608
## agerecAge 25-29                                                                                                           -0.733
## agerecAge 90 or older                                                                                                      5.389
## agerecDon't know/refused                                                                                                   2.592
## maritalDivorced                                                                                                            1.500
## maritalLiving with a partner                                                                                               0.940
## maritalMarried                                                                                                             2.058
## maritalNever been married                                                                                                  2.557
## maritalSeparated                                                                                                           1.561
## maritalWidowed                                                                                                             2.444
## attendA few times a year                                                                                                   1.392
## attendMore than once a week                                                                                                1.403
## attendNever                                                                                                               -3.657
## attendOnce a week                                                                                                          2.397
## attendOnce or twice a month                                                                                                2.487
## attendSeldom                                                                                                              -1.485
## religious_importanceNot at all important                                                                                  -5.435
## religious_importanceNot too important                                                                                      1.356
## religious_importanceSomewhat important                                                                                     7.014
## religious_importanceVery important                                                                                         8.957
##                                                                                                                          Pr(>|z|)
## (Intercept)                                                                                                              0.000278
## income$150,000 or more                                                                                                   0.651860
## income10 to under $20,000                                                                                                0.011069
## income100 to under $150,000                                                                                              0.465053
## income20 to under $30,000                                                                                                0.008405
## income30 to under $40,000                                                                                                0.311455
## income40 to under $50,000                                                                                                0.834978
## income50 to under $75,000                                                                                                0.639730
## income75 to under $100,000                                                                                               0.612022
## incomeLess than $10,000                                                                                                  0.000136
## educFour year college or university degree/Bachelor's degree (e.g., BS, BA, AB)                                          0.103930
## educHigh school graduate (Grade 12 with diploma or GED certificate)                                                      0.030437
## educHigh school incomplete (Grades 9-11 or Grade 12 with NO diploma)                                                     0.079269
## educLess than high school (Grades 1-8 or no formal schooling)                                                            0.013176
## educPostgraduate or professional degree, including master's, doctorate, medical or law degree (e.g., MA, MS, PhD, MD...) 0.107458
## educSome college, no degree (includes some community college)                                                            0.257834
## educSome postgraduate or professional schooling, no postgraduate degree (e.g. some graduate school)                      0.072411
## educTwo year associate degree from a college or university                                                               0.156001
## agerec35-39                                                                                                              0.253811
## agerec40-44                                                                                                              0.616329
## agerec45-49                                                                                                              0.010643
## agerec50-54                                                                                                              0.003870
## agerec55-59                                                                                                              0.000200
## agerec60-64                                                                                                              7.64e-07
## agerec65-69                                                                                                              7.70e-13
## agerec70-74                                                                                                              3.26e-08
## agerec75-79                                                                                                              2.01e-11
## agerec80-84                                                                                                              1.93e-10
## agerec85-89                                                                                                              4.55e-13
## agerecAge 24 or younger                                                                                                  0.543396
## agerecAge 25-29                                                                                                          0.463629
## agerecAge 90 or older                                                                                                    7.08e-08
## agerecDon't know/refused                                                                                                 0.009545
## maritalDivorced                                                                                                          0.133687
## maritalLiving with a partner                                                                                             0.347146
## maritalMarried                                                                                                           0.039560
## maritalNever been married                                                                                                0.010544
## maritalSeparated                                                                                                         0.118581
## maritalWidowed                                                                                                           0.014542
## attendA few times a year                                                                                                 0.163967
## attendMore than once a week                                                                                              0.160547
## attendNever                                                                                                              0.000255
## attendOnce a week                                                                                                        0.016552
## attendOnce or twice a month                                                                                              0.012887
## attendSeldom                                                                                                             0.137621
## religious_importanceNot at all important                                                                                 5.47e-08
## religious_importanceNot too important                                                                                    0.175246
## religious_importanceSomewhat important                                                                                   2.31e-12
## religious_importanceVery important                                                                                        < 2e-16
##                                                                                                                             
## (Intercept)                                                                                                              ***
## income$150,000 or more                                                                                                      
## income10 to under $20,000                                                                                                *  
## income100 to under $150,000                                                                                                 
## income20 to under $30,000                                                                                                ** 
## income30 to under $40,000                                                                                                   
## income40 to under $50,000                                                                                                   
## income50 to under $75,000                                                                                                   
## income75 to under $100,000                                                                                                  
## incomeLess than $10,000                                                                                                  ***
## educFour year college or university degree/Bachelor's degree (e.g., BS, BA, AB)                                             
## educHigh school graduate (Grade 12 with diploma or GED certificate)                                                      *  
## educHigh school incomplete (Grades 9-11 or Grade 12 with NO diploma)                                                     .  
## educLess than high school (Grades 1-8 or no formal schooling)                                                            *  
## educPostgraduate or professional degree, including master's, doctorate, medical or law degree (e.g., MA, MS, PhD, MD...)    
## educSome college, no degree (includes some community college)                                                               
## educSome postgraduate or professional schooling, no postgraduate degree (e.g. some graduate school)                      .  
## educTwo year associate degree from a college or university                                                                  
## agerec35-39                                                                                                                 
## agerec40-44                                                                                                                 
## agerec45-49                                                                                                              *  
## agerec50-54                                                                                                              ** 
## agerec55-59                                                                                                              ***
## agerec60-64                                                                                                              ***
## agerec65-69                                                                                                              ***
## agerec70-74                                                                                                              ***
## agerec75-79                                                                                                              ***
## agerec80-84                                                                                                              ***
## agerec85-89                                                                                                              ***
## agerecAge 24 or younger                                                                                                     
## agerecAge 25-29                                                                                                             
## agerecAge 90 or older                                                                                                    ***
## agerecDon't know/refused                                                                                                 ** 
## maritalDivorced                                                                                                             
## maritalLiving with a partner                                                                                                
## maritalMarried                                                                                                           *  
## maritalNever been married                                                                                                *  
## maritalSeparated                                                                                                            
## maritalWidowed                                                                                                           *  
## attendA few times a year                                                                                                    
## attendMore than once a week                                                                                                 
## attendNever                                                                                                              ***
## attendOnce a week                                                                                                        *  
## attendOnce or twice a month                                                                                              *  
## attendSeldom                                                                                                                
## religious_importanceNot at all important                                                                                 ***
## religious_importanceNot too important                                                                                       
## religious_importanceSomewhat important                                                                                   ***
## religious_importanceVery important                                                                                       ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 45368  on 34889  degrees of freedom
## Residual deviance: 39146  on 34841  degrees of freedom
## AIC: 39244
## 
## Number of Fisher Scoring iterations: 4


Key Findings:
  • Significant Predictors: Variables such as income levels (especially the lowest income bracket), educational attainment, age categories, marital status, frequency of attending religious services, and the importance placed on religion are significant predictors in your model. These factors exhibit a range of influences, with some increasing and others decreasing the likelihood of changing religious affiliation.

    For example:

    • Lower income and older age groups significantly predict changes in religious beliefs.
    • Higher levels of religious importance significantly decrease the likelihood of changing religious affiliation.
Visualization and Further Analysis:

To better understand the model performance and to ensure the robustness of the findings, consider visualizing the following:

  • Residual Plots: Check residuals to assess any systematic deviations that could indicate model mis-specifications.
  • ROC Curve: Generate an ROC curve to evaluate the diagnostic ability of the model across various classification thresholds.
  • Predicted vs. Actual: Plotting predicted probabilities against actual outcomes can help visualize the model’s accuracy in predicting changes in religious affiliation.


# Extract residuals
residuals_data <- data.frame(Residuals = residuals(glm_model, type = "deviance"))

# For logistic regression, residuals won't be perfectly normal, but let's visualize:

ggplot(residuals_data, aes(x = seq_along(Residuals), y = Residuals)) +
  geom_point(alpha = 0.5) +
  labs(x = "Index", y = "Residuals", title = "Plot of Residuals") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5))

p <- ggplot(residuals_data, aes(x = Residuals)) +
  geom_histogram(aes(y = ..density..), bins = 30, fill = "blue", alpha = 0.5) +
  geom_density(color = "red") +
  labs(x = "Residuals", y = "Density", title = "Histogram and Density Plot of Residuals") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5))

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 600)

# Show the interactive plot in your default browser
interactive_plot


These observations can inform us about the model fit. While a degree of asymmetry in residuals can be expected in logistic regression, significant deviations from the expected distribution may suggest model mis-specifications, non-linearity in the data that the model hasn’t captured.


ROC curve
# Assuming you have a binary outcome
probabilities <- predict(glm_model, type = "response")
roc_curve <- roc(response = data_clean_2014$Religion_Change, predictor = probabilities)
## Setting levels: control = Changed, case = Same
## Setting direction: controls < cases
# Create a data frame for ggplot
roc_data <- data.frame(
  FPR = 1- roc_curve$specificities,
  TPR = roc_curve$sensitivities
)

# Plot ROC curve using ggplot2
 ggplot(roc_data, aes(x = FPR, y = TPR)) +
  geom_line(color = "darkorange") +
  geom_abline(linetype = "dashed") +
  labs(x = "False Positive Rate", y = "True Positive Rate", title = "ROC Curve") +
  theme_minimal() +
  geom_area(alpha = 0.2) +
  geom_segment(aes(x = 0, y = 0, xend = 1, yend = 1), color = "navy", linetype = "dashed") +
  annotate("text", x = 0.5, y = 0.25, label = paste("AUC =", round(auc(roc_curve), 2)), color = "red")


With an AUC of 0.73, the model has good predictive ability, significantly better than random guessing, which would have an AUC of 0.5. An AUC value in the range of 0.7 to 0.8 indicates that the model has a fair discrimination ability to differentiate between the two classes: those who have changed their religious affiliation and those who have not.


# Create a dataframe for ggplot
predictions_data <- data.frame(
  Actual = data_clean_2014$Religion_Change,
  Predicted_Probability = probabilities
)

# Plot Predicted Probabilities vs Actual Outcomes
p <- ggplot(predictions_data, aes(x = Predicted_Probability, fill = Actual)) +
  geom_histogram(position = "identity", alpha = 0.5, bins = 30) +
  labs(x = "Predicted Probability", y = "Count", title = "Predicted vs Actual Outcomes") +
  scale_fill_brewer(palette = "Set1", name = "Actual Outcome") +
  theme_minimal() +
  theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

# Make it interactive
interactive_plot <- ggplotly(p , width = 1200 , height = 600)

# Show the interactive plot in your default browser
interactive_plot


The plot reveals that our model is more adept at predicting instances where individuals retain their childhood religious affiliation (‘Same’ class) than instances where they change their religious beliefs (‘Changed’ class). This discrepancy might stem from an imbalance in the dataset, where there are significantly more cases of one class compared to the other. As a result, the model may have learned the patterns associated with the ‘Same’ class more effectively because there were more examples to learn from, leading to a less robust understanding of the ‘Changed’ class characteristics. Addressing this imbalance could potentially improve the model’s ability to discern the subtler patterns that indicate a shift in religious affiliation.


Conclusion

In Chapter 4, I embarked on an analytical journey to model the dynamics of religious affiliation changes using a transition probability approach. Our exploration aimed to quantify how individuals transition between religious affiliations from childhood to adulthood and to simulate these changes over time within a societal context.

Key Findings:

  • Transition Probabilities: successfully quantified the probabilities of transitioning from one religious affiliation to another. The transition matrix constructed from these probabilities revealed detailed insights into the patterns of religious switching. Notably, significant transitions were observed towards non-affiliation (‘Nothing in particular’), and there was an evident decline in traditional affiliations such as Protestantism and Catholicism.

  • Simulation Insights: The simulation of religious composition over time highlighted potential trends and shifts in religious demographics. It demonstrated how the religious landscape could evolve, emphasizing the growing prevalence of religious non-affiliation alongside the decreasing proportions of established denominations.

  • Steady State Analysis: Our analysis sought to determine if the distribution of religious affiliations would reach a steady state, where the proportions of each religion stabilize over time. The findings suggested that while some form of equilibrium could be anticipated, the religious landscape remains dynamically influenced by various social, cultural, and personal factors.

Methodological Insights:

  • My methodology involved calculating transition probabilities and applying these to simulate the evolution of religious affiliations in a hypothetical population. This approach provided a framework for understanding the fluidity and changing nature of religious identities.

  • The visualization techniques employed, including heatmaps of transition probabilities and time-series graphs of religious compositions, offered a clear and engaging representation of our findings, facilitating a deeper understanding of the underlying dynamics.

Challenges and Limitations:

  • One of the primary challenges was the inherent data imbalance in religious affiliations, which influenced the model’s predictions and interpretations, particularly underrepresenting minority religious groups.

  • Additionally, the model assumptions did not account for external factors such as immigration, birth, and death rates, which are crucial in real-world demographic studies. Future models would benefit from integrating these elements to provide more comprehensive insights.

Implications and Future Directions:

  • The study’s findings are crucial for policymakers, religious leaders, educators, and sociologists as they provide a quantified insight into how religious affiliations are changing over generations. This knowledge can help in crafting strategies that address the needs and preferences of diverse religious groups.

  • Future research could expand upon this foundational work by incorporating more complex demographic models and exploring the impact of socio-political changes on religious affiliations. Further, qualitative studies could complement this quantitative analysis to delve deeper into the reasons behind religious switching.

Refrences

To properly cite the 2014 and 2007 Pew Research Center datasets in APA format, you can structure your references like this:

References

For the 2014 Dataset:

Pew Research Center. (2015). America’s Changing Religious Landscape. Retrieved from https://www.pewresearch.org/religion/2015/05/12/americas-changing-religious-landscape/

For the 2007 Dataset:

Pew Research Center. (2008). U.S. Religious Landscape Survey: Religious Beliefs and Practices. Retrieved from https://www.pewresearch.org/religion/2008/06/01/u-s-religious-landscape-survey-religious-beliefs-and-practices/